diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2015-01-26 11:22:42 -0600 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2015-01-26 11:22:42 -0600 |
commit | f03fbbb009c0df52d363719a592e2ac33577d9a6 (patch) | |
tree | 01671bcc5099ef304faf5ae86d58bbf32f9d0b7c /libc/stdlib | |
parent | 97dc8cb71d96a4bbfda0aa51740433d5da825b6a (diff) | |
parent | 92de8a5f6ffb1ff9f7183fd08d872aa098b75ae2 (diff) |
merge upstream changes
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/_atexit.c | 2 | ||||
-rw-r--r-- | libc/stdlib/malloc-simple/alloc.c | 4 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.c | 2 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.h | 2 | ||||
-rw-r--r-- | libc/stdlib/setenv.c | 11 | ||||
-rw-r--r-- | libc/stdlib/unix_grantpt.c | 2 |
6 files changed, 15 insertions, 8 deletions
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c index ef6772fb5..3faa9f05f 100644 --- a/libc/stdlib/_atexit.c +++ b/libc/stdlib/_atexit.c @@ -257,7 +257,7 @@ struct exit_function attribute_hidden *__new_exitfn(void) efp = realloc(__exit_function_table, (__exit_slots+20)*sizeof(struct exit_function)); if (efp == NULL) { - __set_errno(ENOMEM); + /* __set_errno(ENOMEM); */ goto DONE; } __exit_function_table = efp; diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index 14f384632..a3c068a5b 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -42,8 +42,10 @@ void *malloc(size_t size) result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE, MMAP_FLAGS, 0, 0); - if (result == MAP_FAILED) + if (result == MAP_FAILED) { + __set_errno(ENOMEM); return 0; + } * (size_t *) result = size; return(result + sizeof(size_t)); } diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c index 3253ebda6..2abb5bbdd 100644 --- a/libc/stdlib/malloc-standard/malloc.c +++ b/libc/stdlib/malloc-standard/malloc.c @@ -744,7 +744,7 @@ static void* __malloc_alloc(size_t nb, mstate av) } /* catch all failure paths */ - errno = ENOMEM; + __set_errno(ENOMEM); return 0; } diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h index d945627c6..1a4cc5a62 100644 --- a/libc/stdlib/malloc-standard/malloc.h +++ b/libc/stdlib/malloc-standard/malloc.h @@ -512,7 +512,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #define checked_request2size(req, sz) \ if (REQUEST_OUT_OF_RANGE(req)) { \ - errno = ENOMEM; \ + __set_errno(ENOMEM); \ return 0; \ } \ (sz) = request2size(req); diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c index 00e3f3d65..ecc302536 100644 --- a/libc/stdlib/setenv.c +++ b/libc/stdlib/setenv.c @@ -41,7 +41,7 @@ static char **last_environ; to reuse values once generated for a `setenv' call since we can never free the strings. [in uclibc, we do not] */ static int __add_to_environ(const char *name, const char *value, - int replace) + int replace) { register char **ep; register size_t size; @@ -76,7 +76,7 @@ static int __add_to_environ(const char *name, const char *value, /* We allocated this space; we can extend it. */ new_environ = realloc(last_environ, (size + 2) * sizeof(char *)); if (new_environ == NULL) { - __set_errno(ENOMEM); + /* __set_errno(ENOMEM); */ goto DONE; } if (__environ != last_environ) { @@ -97,7 +97,7 @@ static int __add_to_environ(const char *name, const char *value, var_val = malloc(namelen + 1 + vallen); if (var_val == NULL) { - __set_errno(ENOMEM); + /* __set_errno(ENOMEM); */ goto DONE; } memcpy(var_val, name, namelen); @@ -116,6 +116,11 @@ static int __add_to_environ(const char *name, const char *value, int setenv(const char *name, const char *value, int replace) { + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { + __set_errno(EINVAL); + return -1; + } + /* NB: setenv("VAR", NULL, 1) inserts "VAR=" string */ return __add_to_environ(name, value ? value : "", replace); } diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c index 5dbb7f52d..66c18c0ed 100644 --- a/libc/stdlib/unix_grantpt.c +++ b/libc/stdlib/unix_grantpt.c @@ -68,7 +68,7 @@ pts_name (int fd, char **pts, size_t buf_len) if (! new_buf) { rv = -1; - errno = ENOMEM; + /* __set_errno(ENOMEM); */ break; } buf = new_buf; |