diff options
author | Frank Busse <bb0xfb@gmail.com> | 2020-11-26 17:40:49 +0000 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-12-23 16:50:11 +0000 |
commit | b73c455670c467539a28611be8d30ac421be8441 (patch) | |
tree | 7608aada8d2993568e7253a95fbc47d468701360 /runtime/POSIX/fd.c | |
parent | bb6d9441d15e7205eb64ac4f53a2652940df180e (diff) | |
download | klee-b73c455670c467539a28611be8d30ac421be8441.tar.gz |
posix runtime: getcwd: check malloc and set errno
* failing malloc was not handled before, now returns null/ENOMEM * when path is non-null and size is zero return null/EINVAL
Diffstat (limited to 'runtime/POSIX/fd.c')
-rw-r--r-- | runtime/POSIX/fd.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c index cfd2622f..35d0d315 100644 --- a/runtime/POSIX/fd.c +++ b/runtime/POSIX/fd.c @@ -1351,9 +1351,15 @@ char *getcwd(char *buf, size_t size) { } if (!buf) { - if (!size) - size = 1024; + size = 1024; // typically PATH_MAX buf = malloc(size); + if (!buf) { + errno = ENOMEM; + return NULL; + } + } else if (!size) { + errno = EINVAL; + return NULL; } buf = __concretize_ptr(buf); |