diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-06 18:50:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-06 18:50:39 +0000 |
commit | 0f64621783b3f46a4851826b9f4284e3c9dbeb61 (patch) | |
tree | 352fcb09d9321309ec519dc3144147a24bd64bda /games/fortune | |
parent | 997f28507be542389b846c45806474af6bbfdedc (diff) |
2451 lines of strdup/sprintf/strcpy whacking. mostly ok'd by pjanzen
already, but he may have later changes to make still.
Diffstat (limited to 'games/fortune')
-rw-r--r-- | games/fortune/fortune/fortune.c | 14 | ||||
-rw-r--r-- | games/fortune/strfile/strfile.c | 6 |
2 files changed, 11 insertions, 9 deletions
diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c index bbe88779660..a99dc15718c 100644 --- a/games/fortune/fortune/fortune.c +++ b/games/fortune/fortune/fortune.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fortune.c,v 1.15 2002/05/31 20:40:11 pjanzen Exp $ */ +/* $OpenBSD: fortune.c,v 1.16 2003/04/06 18:50:37 deraadt Exp $ */ /* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: fortune.c,v 1.15 2002/05/31 20:40:11 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: fortune.c,v 1.16 2003/04/06 18:50:37 deraadt Exp $"; #endif #endif /* not lint */ @@ -466,10 +466,12 @@ add_file(percent, file, dir, head, tail, parent) if (dir == NULL) { path = file; was_malloc = FALSE; - } - else { - path = do_malloc((unsigned int) (strlen(dir) + strlen(file) + 2)); - (void) strcat(strcat(strcpy(path, dir), "/"), file); + } else { + size_t len; + + len = (unsigned int) (strlen(dir) + strlen(file) + 2); + path = do_malloc(len); + snprintf(path, len, "%s/%s", dir, file); was_malloc = TRUE; } if ((isdir = is_dir(path)) && parent != NULL) { diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c index c7e73ff89a6..e7ad75dab9c 100644 --- a/games/fortune/strfile/strfile.c +++ b/games/fortune/strfile/strfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */ +/* $OpenBSD: strfile.c,v 1.12 2003/04/06 18:50:37 deraadt Exp $ */ /* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $"; +static char rcsid[] = "$OpenBSD: strfile.c,v 1.12 2003/04/06 18:50:37 deraadt Exp $"; #endif #endif /* not lint */ @@ -301,7 +301,7 @@ getargs(argc, argv) if (*argv) { Infile = *argv; if (*++argv) - (void) strcpy(Outfile, *argv); + (void) strlcpy(Outfile, *argv, sizeof Outfile); } if (!Infile) { puts("No input file name"); |