Use snprintf rather than printf out of paranoia

Obtained from:	OpenBSD
This commit is contained in:
imp 1997-12-24 18:56:03 +00:00
parent 72f8c6ca62
commit 986d085dae
5 changed files with 10 additions and 9 deletions

View File

@ -7,7 +7,7 @@
* If you figure out how to do this on another system,
* please let me know. <gwr@mc.com>
*
* $Id$
* $Id: getether.c,v 1.7 1997/02/22 14:21:05 peter Exp $
*/
#include <sys/types.h>
@ -195,7 +195,7 @@ getether(ifname, eap)
char *enaddr;
int unit = -1; /* which unit to attach */
sprintf(devname, "/dev/%s", ifname);
snprintf(devname, sizeof(devname), "/dev/%s", ifname);
fd = open(devname, 2);
if (fd < 0) {
/* Try without the trailing digit. */

View File

@ -2,7 +2,7 @@
* hwaddr.c - routines that deal with hardware addresses.
* (i.e. Ethernet)
*
* $Id$
* $Id: hwaddr.c,v 1.5 1997/02/22 14:21:07 peter Exp $
*/
#include <sys/types.h>
@ -198,7 +198,7 @@ setarp(s, ia, hafamily, haddr, halen)
extern char *inet_ntoa();
a = inet_ntoa(*ia);
sprintf(buf, "arp -d %s; arp -s %s %s temp",
snprintf(buf, sizeof(buf), "arp -d %s; arp -s %s %s temp",
a, a, haddrtoa(haddr, halen));
if (debug > 2)
report(LOG_INFO, buf);

View File

@ -19,7 +19,7 @@ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
$Id$
$Id: readfile.c,v 1.4 1997/02/22 14:21:09 peter Exp $
************************************************************************/
@ -817,7 +817,8 @@ eval_symbol(symbol, hp)
if ((*symbol)[0] == 'T') { /* generic symbol */
(*symbol)++;
value = get_u_long(symbol);
sprintf(current_tagname, "T%d", (int)value);
snprintf(current_tagname, sizeof(current_tagname),
"T%d", (int)value);
eat_whitespace(symbol);
if ((*symbol)[0] != '=') {
return E_SYNTAX_ERROR;

View File

@ -111,7 +111,7 @@ report(priority, fmt, va_alist)
#else
va_start(ap);
#endif
vsprintf(buf, fmt, ap);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
/*

View File

@ -31,7 +31,7 @@
* 09/28/93 Released version 1.0
* 09/93 Original developed by Gordon W. Ross <gwr@mc.com>
*
* $Id$
* $Id: bootptest.c,v 1.4 1997/02/22 14:21:20 peter Exp $
*/
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
@ -503,7 +503,7 @@ ipaddr_string(ina)
u_char *p;
p = (u_char *) ina;
sprintf(b, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
snprintf(b, sizeof(b), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
return (b);
}