diff options
author | Christopher Faylor <me@cgf.cx> | 2000-10-10 19:24:32 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-10-10 19:24:32 +0000 |
commit | e62ae31192a7528f178d2a6ee38b065d459b33c7 (patch) | |
tree | 0c1532c909e365066c7a8e3e94ad83683da04609 /winsup/cygwin/path.cc | |
parent | a8018ef3361ec589af8f655032946db2ed3a9f45 (diff) | |
download | cygnal-e62ae31192a7528f178d2a6ee38b065d459b33c7.tar.gz cygnal-e62ae31192a7528f178d2a6ee38b065d459b33c7.tar.bz2 cygnal-e62ae31192a7528f178d2a6ee38b065d459b33c7.zip |
* path.cc (cwdstuff::get): Set EINVAL when length is zero.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index cc339973c..3b8ff7d56 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2937,6 +2937,13 @@ char * cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) { MALLOC_CHECK; + + if (ulen == 0) + { + set_errno (EINVAL); + goto out; + } + if (!get_initial ()) /* Get initial cwd and set cwd lock */ return NULL; @@ -2955,7 +2962,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) } else { - if (need_posix && !buf) + if (!buf) buf = (char *) malloc (strlen (tocopy) + 1); strcpy (buf, tocopy); if (!buf[0]) /* Should only happen when chroot */ @@ -2963,8 +2970,10 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) } lock->release (); - syscall_printf ("(%s) = cwdstuff::get (%p, %d, %d, %d)", - buf, buf, ulen, need_posix, with_chroot); + +out: + syscall_printf ("(%s) = cwdstuff::get (%p, %d, %d, %d), errno %d", + buf, buf, ulen, need_posix, with_chroot, errno); MALLOC_CHECK; return buf; } |