commit | 6435d27f9d45d01fbd15bcc3dcd9617b86b825bb | [log] [tgz] |
---|---|---|
author | Elliott Hughes <enh@google.com> | Mon Apr 16 08:48:19 2012 -0700 |
committer | android code review <noreply-gerritcodereview@google.com> | Mon Apr 16 08:48:19 2012 -0700 |
tree | 85ac53d9a88bee1d941e844b7599cf40ccaddfbb | |
parent | 6bc18fa58849a4307cf6ddcfd526d9258e8175fc [diff] | |
parent | e5bf0681473aa98091c1eec4ea174407b54d7ef0 [diff] |
Merge "bionic: fix NULL parameter failure in getcwd()"
diff --git a/libc/unistd/getcwd.c b/libc/unistd/getcwd.c index 1cf80e9..1172445 100644 --- a/libc/unistd/getcwd.c +++ b/libc/unistd/getcwd.c
@@ -26,10 +26,15 @@ * SUCH DAMAGE. */ #include <unistd.h> +#include <errno.h> extern int __getcwd(char * buf, size_t size); char *getcwd(char *buf, size_t size) { + if (buf == NULL || size == 0) { + errno = EINVAL; + return NULL; + } return ( __getcwd(buf, size) < 0 ) ? NULL : buf; }