Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xinstall Throw out home-grown strdup().
details: https://anonhg.NetBSD.org/src/rev/49e71e3d6ff4
branches: trunk
changeset: 514998:49e71e3d6ff4
user: simonb <simonb%NetBSD.org@localhost>
date: Sat Sep 15 16:45:23 2001 +0000
description:
Throw out home-grown strdup().
Error check malloc/strdup return values.
diffstat:
usr.bin/xinstall/xinstall.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (40 lines):
diff -r a0832425f58c -r 49e71e3d6ff4 usr.bin/xinstall/xinstall.c
--- a/usr.bin/xinstall/xinstall.c Sat Sep 15 16:33:53 2001 +0000
+++ b/usr.bin/xinstall/xinstall.c Sat Sep 15 16:45:23 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xinstall.c,v 1.48 2001/09/15 14:55:38 simonb Exp $ */
+/* $NetBSD: xinstall.c,v 1.49 2001/09/15 16:45:23 simonb Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#else
-__RCSID("$NetBSD: xinstall.c,v 1.48 2001/09/15 14:55:38 simonb Exp $");
+__RCSID("$NetBSD: xinstall.c,v 1.49 2001/09/15 16:45:23 simonb Exp $");
#endif
#endif /* not lint */
@@ -195,8 +195,9 @@
dorename = 1;
break;
case 'S':
- stripArgs = (char*)malloc(sizeof(char)*(strlen(optarg)+1));
- strcpy(stripArgs,optarg);
+ stripArgs = strdup(optarg);
+ if (stripArgs == NULL)
+ errx(1, "%s", strerror(ENOMEM));
/* fall through; -S implies -s */
case 's':
dostrip = 1;
@@ -586,6 +587,9 @@
strlen(stripArgs)+
strlen(to_name)));
+ if (cmd == NULL)
+ errx(1, "%s", strerror(ENOMEM));
+
sprintf(cmd, "%s %s %s", stripprog, stripArgs, to_name);
execl(_PATH_BSHELL, "sh", "-c", cmd, NULL);
Home |
Main Index |
Thread Index |
Old Index