delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/11/16/06:48:31

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: Re: [patch#2] Handle NULL and empty pathnames
16 Nov 1998 06:48:31 -0800 :
Message-ID: <19981116093259.A4274.cygnus.cygwin32.developers@cygnus.com>
References: <19981115183107 DOT 16554 AT cygnus DOT com>
Mime-Version: 1.0
To: Mumit Khan <khan AT xraylith DOT wisc DOT edu>, Geoffrey Noer <noer AT cygnus DOT com>
Cc: cygwin32-developers AT cygnus DOT com

I've taken the spirit of your changes and made a macro to handle
this test.  The test is now in path_conv and _open.

FYI, you shouldn't have to take any special action with things like
syscall_printf.  They should detect NULL and handle it gracefully.

-chris

On Mon, Nov 16, 1998 at 02:04:50AM -0600, Mumit Khan wrote:
>On Sun, 15 Nov 1998, Geoffrey Noer wrote:
>
>> Committed.  Thanks, I agree, checking for handling NULL pathnames is
>> probably a good idea...
>> 
>
>Well, in that case, we should handle ``fopen (NULL, ...)'' as well. I
>hate SEGV violation in RTLs when there's way to tell the user there's
>a problem with their code.
>
>Patch attached.
>
>Regards,
>Mumit
>

Content-Description: _open patch to handle NULL pathnames
>Mon Nov 16 01:51:32 1998  Mumit Khan  <khan AT xraylith DOT wisc DOT edu>
>
>	* syscalls.cc (_open): Handle NULL pathnames.
>
>Index: syscalls.cc
>===================================================================
>RCS file: /mounts/sdb5/src/cdk-b20/winsup-snapshot/CVSROOT/winsup/syscalls.cc,v
>retrieving revision 1.1.1.1
>diff -u -3 -p -r1.1.1.1 syscalls.cc
>--- syscalls.cc	1998/11/13 05:46:51	1.1.1.1
>+++ syscalls.cc	1998/11/16 07:53:33
>@@ -459,7 +459,13 @@ _open (const char *unix_path, int flags,
>   mode_t mode = 0;
>   fhandler_base *fh;
> 
>-  syscall_printf ("open (%s, %p)", unix_path, flags);
>+  syscall_printf ("open (%s, %p)", (unix_path) ? unix_path : "(NULL)", flags);
>+
>+  if (! unix_path)
>+    {
>+      set_errno (EFAULT);
>+      goto done;
>+    }
> 
>   /* check for optional mode argument */
>   va_start (ap, flags);
>@@ -490,7 +496,8 @@ _open (const char *unix_path, int flags,
>     set_std_handle (res);
> 
> done:
>-  syscall_printf ("%d = open (%s, %p)", res, unix_path, flags);
>+  syscall_printf ("%d = open (%s, %p)", res, 
>+                  (unix_path) ? unix_path : "(NULL)", flags);
>   return res;
> }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019