mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Fix possible buffer overrun
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@26622 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
87bc78de88
commit
acc206a148
2 changed files with 16 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
|||
2008-06-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: possible buffer overrun fix
|
||||
|
||||
2008-06-08 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Version 1.14.4
|
||||
|
|
|
@ -3640,16 +3640,19 @@ static NSFileManager *fm = nil;
|
|||
#if defined(__MINGW32__)
|
||||
return IMMUTABLE(self);
|
||||
#else
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 1024
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#ifdef HAVE_REALPATH
|
||||
#undef HAVE_REALPATH
|
||||
#endif
|
||||
char newBuf[MAX_PATH];
|
||||
#endif
|
||||
char newBuf[PATH_MAX];
|
||||
#ifdef HAVE_REALPATH
|
||||
|
||||
if (realpath([self fileSystemRepresentation], newBuf) == 0)
|
||||
return IMMUTABLE(self);
|
||||
#else
|
||||
char extra[MAX_PATH];
|
||||
char extra[PATH_MAX];
|
||||
char *dest;
|
||||
const char *name = [self fileSystemRepresentation];
|
||||
const char *start;
|
||||
|
@ -3658,7 +3661,7 @@ static NSFileManager *fm = nil;
|
|||
|
||||
if (name[0] != '/')
|
||||
{
|
||||
if (!getcwd(newBuf, MAX_PATH))
|
||||
if (!getcwd(newBuf, PATH_MAX))
|
||||
{
|
||||
return IMMUTABLE(self); /* Couldn't get directory. */
|
||||
}
|
||||
|
@ -3716,7 +3719,7 @@ static NSFileManager *fm = nil;
|
|||
{
|
||||
*dest++ = '/';
|
||||
}
|
||||
if (&dest[len] >= &newBuf[MAX_PATH])
|
||||
if (&dest[len] >= &newBuf[PATH_MAX])
|
||||
{
|
||||
return IMMUTABLE(self); /* Resolved name too long. */
|
||||
}
|
||||
|
@ -3730,20 +3733,20 @@ static NSFileManager *fm = nil;
|
|||
}
|
||||
if (S_ISLNK(st.st_mode))
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (++num_links > MAXSYMLINKS)
|
||||
{
|
||||
return IMMUTABLE(self); /* Too many links. */
|
||||
}
|
||||
n = readlink(newBuf, buf, MAX_PATH);
|
||||
n = readlink(newBuf, buf, PATH_MAX);
|
||||
if (n < 0)
|
||||
{
|
||||
return IMMUTABLE(self); /* Couldn't resolve. */
|
||||
}
|
||||
buf[n] = '\0';
|
||||
|
||||
if ((n + strlen(end)) >= MAX_PATH)
|
||||
if ((n + strlen(end)) >= PATH_MAX)
|
||||
{
|
||||
return IMMUTABLE(self); /* Path too long. */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue