aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/su/su.c
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1997-08-23 14:09:36 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1997-08-23 14:09:36 +0000
commit84c2e301937e01aca847a2cafe36a3fbd51857a5 (patch)
tree96273d8f3d93959c0114ab94d291157de99d21dc /usr.bin/su/su.c
parentc844b96e151e164b6303e7edf7f3d2f2180c672f (diff)
downloadsrc-84c2e301937e01aca847a2cafe36a3fbd51857a5.tar.gz
src-84c2e301937e01aca847a2cafe36a3fbd51857a5.zip
Prevent a NULL dereferencation when given a garbage command line.
PR: bin/3206 Submitted by: blank@fox.uni-trier.de
Notes
Notes: svn path=/head/; revision=28612
Diffstat (limited to 'usr.bin/su/su.c')
-rw-r--r--usr.bin/su/su.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index a358d7aac0ac..2e44f0c86c8f 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)su.c 8.3 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: su.c,v 1.20 1997/05/10 19:01:32 davidn Exp $";
+ "$Id: su.c,v 1.21 1997/08/12 06:45:43 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -151,7 +151,10 @@ main(argc, argv)
break;
}
- if((nargv = malloc (sizeof (char *) * (argc + 4))) == NULL) {
+ if (user == NULL)
+ usage();
+
+ if ((nargv = malloc (sizeof (char *) * (argc + 4))) == NULL) {
errx(1, "malloc failure");
}