summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2010-03-08 19:34:44 +0000
committerkettenis <kettenis@openbsd.org>2010-03-08 19:34:44 +0000
commit32387799d609d31160c04ca53efdf7c733ff64fa (patch)
tree231d310ddc26b3025fbc38ff36e87d11fc484a27
parentUpdate to tzdata2010e from elsie.nci.nih.gov (diff)
downloadwireguard-openbsd-32387799d609d31160c04ca53efdf7c733ff64fa.tar.xz
wireguard-openbsd-32387799d609d31160c04ca53efdf7c733ff64fa.zip
Check that gl_pathc is bigger than zero before derefencing gl_pathv. While
this shouldn't happen since we specifiy GLOB_NOMAGIC, it doesn't hurt to be paranoid, even if we fix the bug in glob(3) that causes gl_pathc to be zero even if we specify GLOB_NOMAGIC. ok deraadt@
-rw-r--r--libexec/ftpd/popen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c
index 2121a675e4b..d19243b8e35 100644
--- a/libexec/ftpd/popen.c
+++ b/libexec/ftpd/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.23 2009/10/27 23:59:31 deraadt Exp $ */
+/* $OpenBSD: popen.c,v 1.24 2010/03/08 19:34:44 kettenis Exp $ */
/* $NetBSD: popen.c,v 1.5 1995/04/11 02:45:00 cgd Exp $ */
/*
@@ -104,12 +104,13 @@ ftpd_popen(char *program, char *type)
fatal ("Out of memory.");
}
- } else
+ } else if (gl.gl_pathc > 0) {
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;