diff options
author | bitblt <bitblt@cvs.openbsd.org> | 1996-12-07 10:52:07 +0000 |
---|---|---|
committer | bitblt <bitblt@cvs.openbsd.org> | 1996-12-07 10:52:07 +0000 |
commit | e9b6db2513895d0a37dd81facfac323d9e8cefd9 (patch) | |
tree | ee396e7cb9f7bb06f8f284709b45bf0aa97be137 /libexec/ftpd/popen.c | |
parent | b757622587d90f0c3b82f0e1e56ac4c38d3eea8c (diff) |
Checks to see that strdup() worked, dies with error message on failure.
Diffstat (limited to 'libexec/ftpd/popen.c')
-rw-r--r-- | libexec/ftpd/popen.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c index 0bd62a96d7b..1d67f02d9f4 100644 --- a/libexec/ftpd/popen.c +++ b/libexec/ftpd/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.7 1996/10/25 23:59:18 imp Exp $ */ +/* $OpenBSD: popen.c,v 1.8 1996/12/07 10:52:06 bitblt Exp $ */ /* $NetBSD: popen.c,v 1.5 1995/04/11 02:45:00 cgd Exp $ */ /* @@ -107,11 +107,18 @@ ftpd_popen(program, type) memset(&gl, 0, sizeof(gl)); if (glob(argv[argc], flags, NULL, &gl)) { - if (gargc < MAX_GARGV-1) + if (gargc < MAX_GARGV-1) { gargv[gargc++] = strdup(argv[argc]); + if (gargv[gargc -1] == NULL) + fatal ("Out of memory"); + } + } else - for (pop = gl.gl_pathv; *pop && gargc < MAX_GARGV-1; pop++) + for (pop = gl.gl_pathv; *pop && gargc < MAX_GARGV-1; pop++) { gargv[gargc++] = strdup(*pop); + if (gargv[gargc - 1] == NULL) + fatal ("Out of memory"); + } globfree(&gl); } gargv[gargc] = NULL; |