mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Fix buffer overrun
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18644 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fab309a4e8
commit
795cb68a0f
2 changed files with 25 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-02-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSFormat.m: Fix buffer overrun by strlen() when printing
|
||||||
|
c-strings without nul terminators using '%*.*s' format.
|
||||||
|
|
||||||
2004-02-23 Adam Fedor <fedor@gnu.org>
|
2004-02-23 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Source/NSUser.m (NSHomeDirectoryForUser): Allow whitespace
|
* Source/NSUser.m (NSHomeDirectoryForUser): Allow whitespace
|
||||||
|
|
|
@ -1736,12 +1736,28 @@ NSDictionary *locale)
|
||||||
/* This is complicated. We have to transform the multibyte
|
/* This is complicated. We have to transform the multibyte
|
||||||
string into a unicode string. */
|
string into a unicode string. */
|
||||||
const char *str = (const char*)string;
|
const char *str = (const char*)string;
|
||||||
unsigned slen = strlen(str);
|
unsigned slen;
|
||||||
NSStringEncoding enc = GetDefEncoding();
|
NSStringEncoding enc = GetDefEncoding();
|
||||||
|
|
||||||
len = prec != -1 ? (unsigned)prec : slen;
|
if (prec != -1)
|
||||||
if (len > slen)
|
{
|
||||||
len = slen;
|
len = (unsigned)prec;
|
||||||
|
/*
|
||||||
|
* If the actual length is less than the precision,
|
||||||
|
* we use the actual length.
|
||||||
|
*/
|
||||||
|
for (slen = 0; slen < len; slen++)
|
||||||
|
{
|
||||||
|
if (str[slen] == 0)
|
||||||
|
{
|
||||||
|
len = slen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = strlen(str);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate dynamically an array which definitely is long
|
/* Allocate dynamically an array which definitely is long
|
||||||
enough for the wide character version. */
|
enough for the wide character version. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue