mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +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
|
@ -1736,12 +1736,28 @@ NSDictionary *locale)
|
|||
/* This is complicated. We have to transform the multibyte
|
||||
string into a unicode string. */
|
||||
const char *str = (const char*)string;
|
||||
unsigned slen = strlen(str);
|
||||
unsigned slen;
|
||||
NSStringEncoding enc = GetDefEncoding();
|
||||
|
||||
len = prec != -1 ? (unsigned)prec : slen;
|
||||
if (len > slen)
|
||||
len = slen;
|
||||
if (prec != -1)
|
||||
{
|
||||
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
|
||||
enough for the wide character version. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue