mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
(GSToUnicode): In an utf8 sequence, check that the continuation bytes are valid continuation bytes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19105 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bb817b4f33
commit
87676ed0e3
2 changed files with 14 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-04-14 18:20 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/Additions/Unicode.m (GSToUnicode): In an utf8 sequence,
|
||||||
|
check the the continuation bytes are valid continuation bytes.
|
||||||
|
|
||||||
2004-04-13 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-04-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Tools/GNUmakefile:
|
* Tools/GNUmakefile:
|
||||||
|
|
|
@ -1211,8 +1211,15 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
||||||
/* get the codepoint */
|
/* get the codepoint */
|
||||||
for (i = 1; i < sle; i++)
|
for (i = 1; i < sle; i++)
|
||||||
{
|
{
|
||||||
|
if (src[spos + i] < 0x80 || src[spos + i] >= 0xc0)
|
||||||
|
break;
|
||||||
u = (u << 6) | (src[spos + i] & 0x3f);
|
u = (u << 6) | (src[spos + i] & 0x3f);
|
||||||
}
|
}
|
||||||
|
if (i < sle)
|
||||||
|
{
|
||||||
|
result = NO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
u = u & ~(0xffffffff << ((5 * sle) + 1));
|
u = u & ~(0xffffffff << ((5 * sle) + 1));
|
||||||
spos += sle;
|
spos += sle;
|
||||||
}
|
}
|
||||||
|
@ -1270,7 +1277,7 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
||||||
case NSNonLossyASCIIStringEncoding:
|
case NSNonLossyASCIIStringEncoding:
|
||||||
case NSASCIIStringEncoding:
|
case NSASCIIStringEncoding:
|
||||||
case NSISOLatin1StringEncoding:
|
case NSISOLatin1StringEncoding:
|
||||||
case NSUnicodeStringEncoding:
|
case NSUnicodeStringEncoding:
|
||||||
while (spos < slen)
|
while (spos < slen)
|
||||||
{
|
{
|
||||||
if (dpos >= bsize)
|
if (dpos >= bsize)
|
||||||
|
@ -1835,7 +1842,7 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src,
|
||||||
goto bases;
|
goto bases;
|
||||||
|
|
||||||
case NSISOLatin1StringEncoding:
|
case NSISOLatin1StringEncoding:
|
||||||
case NSUnicodeStringEncoding:
|
case NSUnicodeStringEncoding:
|
||||||
base = 256;
|
base = 256;
|
||||||
goto bases;
|
goto bases;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue