Fix for bug 71301. Filtering out potential null characters in the stream. R=cavin, SR=bienvenu

This commit is contained in:
ducarroz%netscape.com 2002-08-12 19:19:57 +00:00
Родитель 398c128889
Коммит 44d302f213
1 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -918,6 +918,30 @@ const char output[] = "\
readLen = aLength;
aIStream->Read(buf, aLength, &readLen);
// We need to filter out any null characters else we will have a lot of trouble
// as we use c string everywhere in mime
char * readPtr;
char * endPtr = buf + readLen;
// First let see if the stream contains null characters
for (readPtr = buf; *readPtr && readPtr < endPtr; readPtr ++)
;
// Did we find a null character? Then, we need to cleanup the stream
if (readPtr < endPtr)
{
char * writePtr = readPtr;
for (readPtr ++; readPtr < endPtr; readPtr ++)
{
if (!*readPtr)
continue;
*writePtr = *readPtr;
writePtr ++;
}
readLen = writePtr - buf;
}
if (mOutputType == nsMimeOutput::nsMimeMessageSource)
{
rc = NS_OK;