From: khan AT xraylith DOT wisc DOT edu (Mumit Khan) Subject: [patch] Handle NULL and empty pathnames 15 Nov 1998 16:54:31 -0800 Message-ID: <9811160034.AA24254.cygnus.cygwin32.developers@modi.xraylith.wisc.edu> To: cygwin32-developers AT cygnus DOT com There've been a few bug reports on winsup's handling of both NULL and empty (ie., "") pathnames. This patch should fix that. Note that POSIX doesn't require handling of NULL pathnames at all, but SVR4 returns EFAULT (Bad address). I'm unsure as to what winsup should do, but being user-friendly doesn't hurt, I'm handling that as well. Sun Nov 15 18:20:43 1998 Mumit Khan * path.cc (mount_info::conv_to_posix_path): Handle NULL and empty pathnames. (mount_info::conv_to_win32_path): Likewise. Index: path.cc =================================================================== RCS file: /mounts/sdb5/src/cdk-b20/winsup-snapshot/CVSROOT/winsup/path.cc,v retrieving revision 1.1.1.1 diff -u -3 -p -r1.1.1.1 path.cc --- path.cc 1998/11/13 05:46:50 1.1.1.1 +++ path.cc 1998/11/16 00:24:44 @@ -576,7 +576,19 @@ int mount_info::conv_to_win32_path (const char *src_path, char *win32_path, char *full_win32_path, DWORD &devn, int &unit) { + if (! src_path) + { + debug_printf ("EFAULT"); + return EFAULT; + } + int src_path_len = strlen (src_path); + if (src_path_len == 0) + { + debug_printf ("ENOENT"); + return ENOENT; + } + int trailing_slash_p = (src_path_len > 0 && SLASH_P (src_path[src_path_len - 1])); @@ -751,7 +763,19 @@ int mount_info::conv_to_posix_path (const char *src_path, char *posix_path, int keep_rel_p) { + if (! src_path) + { + debug_printf ("EFAULT"); + return EFAULT; + } + int src_path_len = strlen (src_path); + if (src_path_len == 0) + { + debug_printf ("ENOENT"); + return ENOENT; + } + int trailing_slash_p = (src_path_len > 0 && SLASH_P (src_path[src_path_len - 1])); int relative_path_p = (! SLASH_P (*src_path)