aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorseebs <seebs@seebs-eee.(none)>2010-08-16 17:20:51 -0500
committerseebs <seebs@seebs-eee.(none)>2010-08-16 17:20:51 -0500
commitb66645f72f9ebc0ab2a8aeaf1df8e8219624f61c (patch)
tree137f1ffd62df5f6b0daf0888ca4f748f63e4781e /guts
parent4416ede8800ec2652b40d72be3080c2416874074 (diff)
downloadpseudo-b66645f72f9ebc0ab2a8aeaf1df8e8219624f61c.tar.gz
pseudo-b66645f72f9ebc0ab2a8aeaf1df8e8219624f61c.tar.bz2
pseudo-b66645f72f9ebc0ab2a8aeaf1df8e8219624f61c.zip
A few minor fixes:
Fixed a couple of allocation issues, corrected an off-by-one error in environment setup.
Diffstat (limited to 'guts')
-rw-r--r--guts/execl.c12
-rw-r--r--guts/execle.c12
-rw-r--r--guts/execlp.c12
3 files changed, 36 insertions, 0 deletions
diff --git a/guts/execl.c b/guts/execl.c
index 92a4cdc..d7b477c 100644
--- a/guts/execl.c
+++ b/guts/execl.c
@@ -10,6 +10,12 @@
size_t i = 0;
size_t alloc_size = 256;
const char **argv = malloc(sizeof (const char *) * alloc_size);
+ if (!argv) {
+ pseudo_debug(1, "execl failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
argv[i++] = arg;
@@ -18,6 +24,12 @@
if ( i > alloc_size - 1 ) {
alloc_size = alloc_size + 256;
argv = realloc(argv, sizeof (const char *) * alloc_size);
+ if (!argv) {
+ pseudo_debug(1, "execl failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
}
}
diff --git a/guts/execle.c b/guts/execle.c
index f4c2ea7..13fbfb9 100644
--- a/guts/execle.c
+++ b/guts/execle.c
@@ -11,6 +11,12 @@
size_t alloc_size = 256;
const char **argv = malloc(sizeof (const char *) * alloc_size);
char *const *envp;
+ if (!argv) {
+ pseudo_debug(1, "execle failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
argv[i++] = arg;
@@ -19,6 +25,12 @@
if ( i > alloc_size - 1 ) {
alloc_size = alloc_size + 256;
argv = realloc(argv, sizeof (const char *) * alloc_size);
+ if (!argv) {
+ pseudo_debug(1, "execle failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
}
}
envp = va_arg (ap, char *const *);
diff --git a/guts/execlp.c b/guts/execlp.c
index 8fd2cdf..d09a64d 100644
--- a/guts/execlp.c
+++ b/guts/execlp.c
@@ -10,6 +10,12 @@
size_t i = 0;
size_t alloc_size = 256;
const char **argv = malloc(sizeof (const char *) * alloc_size);
+ if (!argv) {
+ pseudo_debug(1, "execlp failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
argv[i++] = arg;
@@ -18,6 +24,12 @@
if ( i > alloc_size - 1 ) {
alloc_size = alloc_size + 256;
argv = realloc(argv, sizeof (const char *) * alloc_size);
+ if (!argv) {
+ pseudo_debug(1, "execlp failed: couldn't allocate memory for %lu arguments\n",
+ (unsigned long) alloc_size);
+ errno = ENOMEM;
+ return -1;
+ }
}
}