diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-25 20:07:10 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-25 20:07:10 +0000 |
commit | e294f1e17d0e66df5e6f777424a6fa89f3dd1a63 (patch) | |
tree | 1ee310fde6f677d6f3151193815430dba5ad415a | |
parent | 14f6abdffc727eeddbcea128909598e7ffd9dfaa (diff) |
check asprintf return value for error, as the pointer is not guaranteed
to be NULL in such case; ok millert
-rw-r--r-- | usr.bin/ctags/ctags.c | 14 | ||||
-rw-r--r-- | usr.bin/newsyslog/newsyslog.c | 7 | ||||
-rw-r--r-- | usr.bin/pmdb/aout_syms.c | 5 | ||||
-rw-r--r-- | usr.bin/telnet/commands.c | 5 |
4 files changed, 13 insertions, 18 deletions
diff --git a/usr.bin/ctags/ctags.c b/usr.bin/ctags/ctags.c index bb69b3aa7a6..0affda6c26e 100644 --- a/usr.bin/ctags/ctags.c +++ b/usr.bin/ctags/ctags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctags.c,v 1.7 2003/04/07 21:13:54 deraadt Exp $ */ +/* $OpenBSD: ctags.c,v 1.8 2003/04/25 20:07:09 pvalchev Exp $ */ /* $NetBSD: ctags.c,v 1.4 1995/09/02 05:57:23 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ctags.c 8.4 (Berkeley) 2/7/95"; #endif -static char rcsid[] = "$OpenBSD: ctags.c,v 1.7 2003/04/07 21:13:54 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ctags.c,v 1.8 2003/04/25 20:07:09 pvalchev Exp $"; #endif /* not lint */ #include <err.h> @@ -160,10 +160,9 @@ usage: (void)fprintf(stderr, else { if (uflag) { for (step = 0; step < argc; step++) { - (void)asprintf(&cmd, + if (asprintf(&cmd, "mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS", - outfile, argv[step], outfile); - if (cmd == NULL) + outfile, argv[step], outfile) == -1) err(1, "out of space"); system(cmd); free(cmd); @@ -176,9 +175,8 @@ usage: (void)fprintf(stderr, put_entries(head); (void)fclose(outf); if (uflag) { - (void)asprintf(&cmd, "sort -o %s %s", - outfile, outfile); - if (cmd == NULL) + if (asprintf(&cmd, "sort -o %s %s", + outfile, outfile) == -1) err(1, "out of space"); system(cmd); free(cmd); diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c index 975020fd5b6..ca8c5daae52 100644 --- a/usr.bin/newsyslog/newsyslog.c +++ b/usr.bin/newsyslog/newsyslog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newsyslog.c,v 1.63 2003/02/12 19:17:36 millert Exp $ */ +/* $OpenBSD: newsyslog.c,v 1.64 2003/04/25 20:07:09 pvalchev Exp $ */ /* * Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -86,7 +86,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.63 2003/02/12 19:17:36 millert Exp $"; +static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.64 2003/04/25 20:07:09 pvalchev Exp $"; #endif /* not lint */ #ifndef CONF @@ -1079,8 +1079,7 @@ openmail(void) FILE *ret; char *cmdbuf = NULL; - asprintf(&cmdbuf, "%s -t", SENDMAIL); - if (cmdbuf) { + if (asprintf(&cmdbuf, "%s -t", SENDMAIL) != -1) { ret = popen(cmdbuf, "w"); free(cmdbuf); return (ret); diff --git a/usr.bin/pmdb/aout_syms.c b/usr.bin/pmdb/aout_syms.c index d3b2147b139..aff29d1eec8 100644 --- a/usr.bin/pmdb/aout_syms.c +++ b/usr.bin/pmdb/aout_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aout_syms.c,v 1.9 2002/07/22 01:20:50 art Exp $ */ +/* $OpenBSD: aout_syms.c,v 1.10 2003/04/25 20:07:09 pvalchev Exp $ */ /* * Copyright (c) 2002 Federico Schwindt <fgsch@openbsd.org> * All rights reserved. @@ -253,8 +253,7 @@ restart: if (s == NULL) { if (first) { - asprintf(&sname, "_%s", sname); - if (sname != NULL) { + if (asprintf(&sname, "_%s", sname) != -1) { first = 0; goto restart; } diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 55d5755224a..2a9a2446163 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.43 2003/04/03 12:05:58 hin Exp $ */ +/* $OpenBSD: commands.c,v 1.44 2003/04/25 20:07:09 pvalchev Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -1680,8 +1680,7 @@ env_init() hbuf[sizeof hbuf-1] = '\0'; } - asprintf (&cp, "%s%s", hbuf, cp2); - if (cp == NULL) + if (asprintf (&cp, "%s%s", hbuf, cp2) == -1) err(1, "asprintf"); free(ep->value); |