diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
commit | cd64a50f546ecbfd25035373ee745bd04e4e5905 (patch) | |
tree | 86a1452cec538b8f5259a45745e95cd1161d04e7 /bin | |
parent | 6153e3b8d9aedd43b1300c4d60217039c9485e02 (diff) |
lots of sprintf -> snprintf and strcpy -> strlcpy; checked by tedu
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cp/cp.c | 6 | ||||
-rw-r--r-- | bin/mv/mv.c | 6 | ||||
-rw-r--r-- | bin/rmail/rmail.c | 10 |
3 files changed, 12 insertions, 10 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c index 80222030835..ee8e50b7cea 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cp.c,v 1.21 2003/01/06 01:52:52 millert Exp $ */ +/* $OpenBSD: cp.c,v 1.22 2003/03/13 09:09:20 deraadt Exp $ */ /* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95"; #else -static char rcsid[] = "$OpenBSD: cp.c,v 1.21 2003/01/06 01:52:52 millert Exp $"; +static char rcsid[] = "$OpenBSD: cp.c,v 1.22 2003/03/13 09:09:20 deraadt Exp $"; #endif #endif /* not lint */ @@ -188,7 +188,7 @@ main(int argc, char *argv[]) target = argv[--argc]; if (strlen(target) >= sizeof(to.p_path)) errx(1, "%s: name too long", target); - (void)strcpy(to.p_path, target); + (void)strlcpy(to.p_path, target, sizeof to.p_path); to.p_end = to.p_path + strlen(to.p_path); if (to.p_path == to.p_end) { *to.p_end++ = '.'; diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 43743409013..059fff2ba7d 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mv.c,v 1.24 2002/07/04 04:26:40 deraadt Exp $ */ +/* $OpenBSD: mv.c,v 1.25 2003/03/13 09:09:24 deraadt Exp $ */ /* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: mv.c,v 1.24 2002/07/04 04:26:40 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mv.c,v 1.25 2003/03/13 09:09:24 deraadt Exp $"; #endif #endif /* not lint */ @@ -122,7 +122,7 @@ main(int argc, char *argv[]) /* It's a directory, move each file into it. */ if (strlen(argv[argc - 1]) > sizeof path - 1) errx(1, "%s: destination pathname too long", *argv); - (void)strcpy(path, argv[argc - 1]); + (void)strlcpy(path, argv[argc - 1], sizeof path); baselen = strlen(path); endp = &path[baselen]; if (*(endp - 1) != '/') { diff --git a/bin/rmail/rmail.c b/bin/rmail/rmail.c index 6a19ca449aa..7e220b17ce5 100644 --- a/bin/rmail/rmail.c +++ b/bin/rmail/rmail.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmail.c,v 1.13 2002/07/04 04:26:40 deraadt Exp $ */ +/* $OpenBSD: rmail.c,v 1.14 2003/03/13 09:09:24 deraadt Exp $ */ /* $NetBSD: rmail.c,v 1.8 1995/09/07 06:51:50 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)rmail.c 8.3 (Berkeley) 5/15/95"; #else -static char rcsid[] = "$OpenBSD: rmail.c,v 1.13 2002/07/04 04:26:40 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rmail.c,v 1.14 2003/03/13 09:09:24 deraadt Exp $"; #endif #endif /* not lint */ @@ -283,9 +283,11 @@ main(int argc, char *argv[]) if (strchr(*argv, ',') == NULL || strchr(*argv, '<') != NULL) args[i++] = *argv; else { - if ((args[i] = malloc(strlen(*argv) + 3)) == NULL) + int len = strlen(*argv) + 3; + + if ((args[i] = malloc(len)) == NULL) err(EX_TEMPFAIL, "Cannot malloc"); - sprintf (args [i++], "<%s>", *argv); + snprintf(args[i++], len, "<%s>", *argv); } argv++; } |