aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
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;
+ }
}
}