]> granicus.if.org Git - python/commitdiff
OS/2 specific fixes related to SF bug # 1003471
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>
Sun, 12 Dec 2004 08:28:11 +0000 (08:28 +0000)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>
Sun, 12 Dec 2004 08:28:11 +0000 (08:28 +0000)
PC/os2emx/getpathp.c
PC/os2vacpp/getpathp.c

index 4a4c89394530be4fc5ec37b1eadfa557ef728ca8..7bfd19e0ce3755f4820be11d2ab1ea20e98f7573 100644 (file)
@@ -132,7 +132,16 @@ ismodule(char *filename)
        return 0;
 }
 
-/* guarantees buffer will never overflow MAXPATHLEN+1 bytes */
+/* Add a path component, by appending stuff to buffer.
+   buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a
+   NUL-terminated string with no more than MAXPATHLEN characters (not counting
+   the trailing NUL).  It's a fatal error if it contains a string longer than
+   that (callers must be careful!).  If these requirements are met, it's
+   guaranteed that buffer will still be a NUL-terminated string with no more
+   than MAXPATHLEN characters at exit.  If stuff is too long, only as much of
+   stuff as fits will be appended.
+*/
+
 static void
 join(char *buffer, char *stuff)
 {
@@ -144,6 +153,8 @@ join(char *buffer, char *stuff)
                if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN)
                        buffer[n++] = SEP;
        }
+       if (n > MAXPATHLEN)
+               Py_FatalError("buffer overflow in getpathp.c's joinpath()");
        k = strlen(stuff);
        if (n + k > MAXPATHLEN)
                k = MAXPATHLEN - n;
index 5860e752c350a791abd87f970fb2658753b97013..607f2a192a56a327d16d317f187132081fa9e3f3 100644 (file)
@@ -83,6 +83,15 @@ exists(char *filename)
 }
 
 
+/* Add a path component, by appending stuff to buffer.
+   buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a
+   NUL-terminated string with no more than MAXPATHLEN characters (not counting
+   the trailing NUL).  It's a fatal error if it contains a string longer than
+   that (callers must be careful!).  If these requirements are met, it's
+   guaranteed that buffer will still be a NUL-terminated string with no more
+   than MAXPATHLEN characters at exit.  If stuff is too long, only as much of
+   stuff as fits will be appended.
+*/
 static void
 join(char *buffer, char *stuff)
 {
@@ -94,6 +103,8 @@ join(char *buffer, char *stuff)
                if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN)
                        buffer[n++] = SEP;
        }
+       if (n > MAXPATHLEN)
+               Py_FatalError("buffer overflow in getpathp.c's joinpath()");
        k = strlen(stuff);
        if (n + k > MAXPATHLEN)
                k = MAXPATHLEN - n;