remove dangerous sprintf and strcpy calls.

This commit is contained in:
mrg 1997-02-11 08:26:27 +00:00
parent a4d8e69073
commit cc03262905
3 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: edit.c,v 1.7 1996/08/09 09:22:16 thorpej Exp $ */
/* $NetBSD: edit.c,v 1.8 1997/02/11 08:26:27 mrg Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
#else
static char rcsid[] = "$NetBSD: edit.c,v 1.7 1996/08/09 09:22:16 thorpej Exp $";
static char rcsid[] = "$NetBSD: edit.c,v 1.8 1997/02/11 08:26:27 mrg Exp $";
#endif
#endif /* not lint */
@ -210,7 +210,7 @@ bad: (void)fclose(fp);
strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) + 4;
if (!(p = malloc(len)))
err(1, NULL);
(void)sprintf(pw->pw_gecos = p, "%s,%s,%s,%s", list[E_NAME].save,
(void)snprintf(pw->pw_gecos = p, len, "%s,%s,%s,%s", list[E_NAME].save,
list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save);
if (snprintf(buf, sizeof(buf),

View File

@ -1,4 +1,4 @@
/* $NetBSD: pw_yp.c,v 1.7 1996/11/26 23:38:44 thorpej Exp $ */
/* $NetBSD: pw_yp.c,v 1.8 1997/02/11 08:26:27 mrg Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@ -36,7 +36,7 @@
#if 0
static char sccsid[] = "@(#)pw_yp.c 1.0 2/2/93";
#else
static char rcsid[] = "$NetBSD: pw_yp.c,v 1.7 1996/11/26 23:38:44 thorpej Exp $";
static char rcsid[] = "$NetBSD: pw_yp.c,v 1.8 1997/02/11 08:26:27 mrg Exp $";
#endif
#endif /* not lint */
@ -260,7 +260,7 @@ ypgetpwnam(nam)
break;
}
val[vallen] = '\0';
strcpy(line, val);
(void)strncpy(line, val, sizeof(line) - 1);
free(val);
return(interpret(&pwent, line));
@ -280,7 +280,7 @@ ypgetpwuid(uid)
errx(1, "can't get local YP domain. Reason: %s\n",
yperr_string(reason));
sprintf(namebuf, "%d", uid);
(void)snprintf(namebuf, sizeof namebuf, "%d", uid);
reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf),
&val, &vallen);
switch(reason) {
@ -291,7 +291,7 @@ ypgetpwuid(uid)
break;
}
val[vallen] = '\0';
strcpy(line, val);
(void)strncpy(line, val, sizeof(line) - 1);
free(val);
return(interpret(&pwent, line));

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.4 1995/03/26 04:55:35 glass Exp $ */
/* $NetBSD: util.c,v 1.5 1997/02/11 08:26:28 mrg Exp $ */
/*-
* Copyright (c) 1988, 1993, 1994
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
#else
static char rcsid[] = "$NetBSD: util.c,v 1.4 1995/03/26 04:55:35 glass Exp $";
static char rcsid[] = "$NetBSD: util.c,v 1.5 1997/02/11 08:26:28 mrg Exp $";
#endif
#endif /* not lint */
@ -71,7 +71,7 @@ ttoa(tval)
if (tval) {
tp = localtime(&tval);
(void)sprintf(tbuf, "%s %d, %d", months[tp->tm_mon],
(void)snprintf(tbuf, sizeof tbuf, "%s %d, %d", months[tp->tm_mon],
tp->tm_mday, tp->tm_year + TM_YEAR_BASE);
}
else