From d21edf5276c8aa21f703f926314444e8080a2dbe Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 21 Jun 2013 08:14:26 +0000 Subject: [PATCH] * path.cc (cygwin_conv_path): Handle NULL "from" path gracefully. * path.sgml (func-cygwin-conv-path): Document returning EINVAL if "from" is NULL. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/path.cc | 6 ++++++ winsup/cygwin/path.sgml | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index be9863eb3..f101a9515 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2013-06-21 Corinna Vinschen + + * path.cc (cygwin_conv_path): Handle NULL "from" path gracefully. + * path.sgml (func-cygwin-conv-path): Document returning EINVAL if + "from" is NULL. + 2013-06-19 Christopher Faylor * winf.h (av::unshift): Make __reg2. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 9492590c3..9f4a3b5a6 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3212,6 +3212,12 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to, bool relative = !!(what & CCP_RELATIVE); what &= CCP_CONVTYPE_MASK; + if (!from) + { + set_errno (EINVAL); + return -1; + } + switch (what) { case CCP_POSIX_TO_WIN_A: diff --git a/winsup/cygwin/path.sgml b/winsup/cygwin/path.sgml index 26c3ea34e..79f97dff5 100644 --- a/winsup/cygwin/path.sgml +++ b/winsup/cygwin/path.sgml @@ -42,7 +42,7 @@ buffer size in bytes. Otherwise, it returns 0 on success, or -1 on error and errno is set to one of the below values. - EINVAL what has an invalid value. + EINVAL what has an invalid value or from is NULL. EFAULT from or to point into nirvana. ENAMETOOLONG the resulting path is longer than 32K, or, in case of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.