summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbitblt <bitblt@openbsd.org>1996-12-07 10:52:06 +0000
committerbitblt <bitblt@openbsd.org>1996-12-07 10:52:06 +0000
commitae4e5bf96e60aef53fab636f42136bb4156c2611 (patch)
tree5261ff9b45b9b2a143f15fbdbbf853e04dcf5f62
parentcorrect a sigsegv during parsing of garbled input; netbsd pr#2659, dgilbert@jaywon.pci.on.ca (diff)
downloadwireguard-openbsd-ae4e5bf96e60aef53fab636f42136bb4156c2611.tar.xz
wireguard-openbsd-ae4e5bf96e60aef53fab636f42136bb4156c2611.zip
Checks to see that strdup() worked, dies with error message on failure.
-rw-r--r--libexec/ftpd/popen.c13
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;