diff options
author | Jack Ren <jack.ren@intel.com> | 2012-03-13 18:26:28 +0800 |
---|---|---|
committer | Jack Ren <jack.ren@intel.com> | 2012-04-16 23:35:05 +0800 |
commit | e5bf0681473aa98091c1eec4ea174407b54d7ef0 (patch) | |
tree | 85ac53d9a88bee1d941e844b7599cf40ccaddfbb | |
parent | 6bc18fa58849a4307cf6ddcfd526d9258e8175fc (diff) | |
download | bionic-e5bf0681473aa98091c1eec4ea174407b54d7ef0.zip bionic-e5bf0681473aa98091c1eec4ea174407b54d7ef0.tar.gz bionic-e5bf0681473aa98091c1eec4ea174407b54d7ef0.tar.bz2 |
bionic: fix NULL parameter failure in getcwd()
LTP: getcwd01 failed in LTP
Need to check getcwd parameters, otherwise it will lead to
posix test case to fail.
Change-Id: Ieb673b6dd4ca6481da81c5339dbf7ec0a463f263
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
-rw-r--r-- | libc/unistd/getcwd.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; } |