summaryrefslogtreecommitdiff
path: root/PC/os2vacpp
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-12-12 08:28:11 +0000
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2004-12-12 08:28:11 +0000
commit3e6d0e9ae6c7bf1bbe234bb9b230606621165e5f (patch)
treebc2f7f3b44817e6c76fc45ed9e6238c610d8a988 /PC/os2vacpp
parentf6dfe20bf306ab3da1d58c9d304bda0d919c5998 (diff)
downloadcpython-3e6d0e9ae6c7bf1bbe234bb9b230606621165e5f.tar.gz
OS/2 specific fixes related to SF bug # 1003471
Diffstat (limited to 'PC/os2vacpp')
-rw-r--r--PC/os2vacpp/getpathp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/PC/os2vacpp/getpathp.c b/PC/os2vacpp/getpathp.c
index 5860e752c3..607f2a192a 100644
--- a/PC/os2vacpp/getpathp.c
+++ b/PC/os2vacpp/getpathp.c
@@ -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;