bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12945: Assume POSIX 1003.1-1988 or later for unistd.h.


From: Eli Zaretskii
Subject: bug#12945: Assume POSIX 1003.1-1988 or later for unistd.h.
Date: Tue, 20 Nov 2012 22:13:35 +0200

> Date: Tue, 20 Nov 2012 20:14:55 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 12945@debbugs.gnu.org
> 
> > It may help in a later patch to simplify the Microsoft side by
> > removing getwd and standardizing on getcwd, since that's what
> > POSIX did back in 1988, but that's an issue that's independent
> > of this patch.
> 
> It's not independent.  The getwd in w32.c must be modified to be
> getcwd instead.

Here's the patch for that:

=== modified file 'src/w32.c'
--- src/w32.c   2012-11-17 22:12:47 +0000
+++ src/w32.c   2012-11-20 20:11:08 +0000
@@ -901,8 +901,18 @@ static char startup_dir[MAXPATHLEN];
 
 /* Get the current working directory.  */
 char *
-getwd (char *dir)
+getcwd (char *dir, int dirsize)
 {
+  if (!dirsize)
+    {
+      errno = EINVAL;
+      return NULL;
+    }
+  if (dirsize < strlen (startup_dir) + 1)
+    {
+      errno = ERANGE;
+      return NULL;
+    }
 #if 0
   if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
     return dir;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]