summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-05-07 15:51:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-05-07 15:51:13 +0000
commit579286749b643c38139a6825919acc2acf424273 (patch)
treeb2e06d2f5b7b5208fd9052347c12a6f90428ee41
parent8fe069866ca23e3b9d9f6a304e2eee1040aeff8f (diff)
Fix some sizeof(ptr) bugs based on diffs from aaron@.
Note that this is not code that actually gets compiled.
-rw-r--r--usr.bin/netstat/iso.c6
-rw-r--r--usr.sbin/amd/mk-amd-map/mk-amd-map.c21
2 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/netstat/iso.c b/usr.bin/netstat/iso.c
index 2738f15cd98..07b94ee10b0 100644
--- a/usr.bin/netstat/iso.c
+++ b/usr.bin/netstat/iso.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iso.c,v 1.14 2004/03/13 22:02:13 deraadt Exp $ */
+/* $OpenBSD: iso.c,v 1.15 2004/05/07 15:51:11 millert Exp $ */
/* $NetBSD: iso.c,v 1.12 1995/10/03 21:42:38 thorpej Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)iso.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: iso.c,v 1.14 2004/03/13 22:02:13 deraadt Exp $";
+static char *rcsid = "$OpenBSD: iso.c,v 1.15 2004/05/07 15:51:11 millert Exp $";
#endif
#endif /* not lint */
@@ -417,7 +417,7 @@ isonetprint(struct iso_addr *iso, char *sufx, u_short sufxlen, int islocal)
if (!nflag) {
if ((cp -line)>10) {
cp = line+10;
- bzero(cp, sizeof(line)-10);
+ bzero(cp, strlen(cp));
}
}
diff --git a/usr.sbin/amd/mk-amd-map/mk-amd-map.c b/usr.sbin/amd/mk-amd-map/mk-amd-map.c
index 5c635bfd4b6..3bac267fdd9 100644
--- a/usr.sbin/amd/mk-amd-map/mk-amd-map.c
+++ b/usr.sbin/amd/mk-amd-map/mk-amd-map.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93
- * $Id: mk-amd-map.c,v 1.7 2003/06/02 23:36:52 millert Exp $
+ * $Id: mk-amd-map.c,v 1.8 2004/05/07 15:51:12 millert Exp $
*/
/*
@@ -48,7 +48,7 @@ char copyright[] = "\
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$Id: mk-amd-map.c,v 1.7 2003/06/02 23:36:52 millert Exp $";
+static char rcsid[] = "$Id: mk-amd-map.c,v 1.8 2004/05/07 15:51:12 millert Exp $";
static char sccsid[] = "@(#)mk-amd-map.c 8.1 (Berkeley) 6/28/93";
#endif /* not lint */
@@ -267,23 +267,24 @@ main(int argc, char *argv[])
}
if (!printit) {
- len = strlen(map);
#ifdef USING_DB
- mappag = (char *) malloc(len + 5);
+ len = strlen(map) + 4;
+ mappag = (char *) malloc(len);
if (!mappag) {
perror("mk-amd-map: malloc");
exit(1);
}
mktemp(maptmp);
- snprintf(maptpag, sizeof(maptpag), "%s%s", maptmp, DBM_SUFFIX);
+ snprintf(maptpag, sizeof(maptpag), "%s.db", maptmp);
if (remove_file(maptpag) < 0) {
fprintf(stderr, "Can't remove existing temporary file");
perror(maptpag);
exit(1);
}
#else
- mappag = (char *) malloc(len + 5);
- mapdir = (char *) malloc(len + 5);
+ len = strlen(map) + 5;
+ mappag = (char *) malloc(len);
+ mapdir = (char *) malloc(len);
if (!mappag || !mapdir) {
perror("mk-amd-map: malloc");
exit(1);
@@ -325,7 +326,7 @@ main(int argc, char *argv[])
rc = 1;
} else {
#ifdef USING_DB
- snprintf(mappag, sizeof(mappag), "%s%s", map, DBM_SUFFIX);
+ snprintf(mappag, len, "%s.db", map);
if (rename(maptpag, mappag) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptpag);
perror(mappag);
@@ -334,8 +335,8 @@ main(int argc, char *argv[])
rc = 1;
}
#else
- snprintf(mappag, sizeof(mappag), "%s.pag", map);
- snprintf(mapdir, sizeof(mapdir), "%s.dir", map);
+ snprintf(mappag, len, "%s.pag", map);
+ snprintf(mapdir, len, "%s.dir", map);
if (rename(maptpag, mappag) < 0) {
fprintf(stderr, "Couldn't rename %s to ", maptpag);
perror(mappag);