case insensitive HHP files and fixed buffer overflow vulnerability
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,15 +48,22 @@ WX_DEFINE_OBJARRAY(wxHtmlBookRecArray)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Reads one line, stores it into buf and returns pointer to new line or NULL.
|
// Reads one line, stores it into buf and returns pointer to new line or NULL.
|
||||||
static char* ReadLine(char *line, char *buf)
|
static char* ReadLine(char *line, char *buf, size_t bufsize)
|
||||||
{
|
{
|
||||||
char *writeptr = buf, *readptr = line;
|
char *writeptr = buf;
|
||||||
|
char *endptr = buf + bufsize - 1;
|
||||||
|
char *readptr = line;
|
||||||
|
|
||||||
while (*readptr != 0 && *readptr != '\r' && *readptr != '\n') *(writeptr++) = *(readptr++);
|
while (*readptr != 0 && *readptr != '\r' && *readptr != '\n' &&
|
||||||
|
writeptr != endptr)
|
||||||
|
*(writeptr++) = *(readptr++);
|
||||||
*writeptr = 0;
|
*writeptr = 0;
|
||||||
while (*readptr == '\r' || *readptr == '\n') readptr++;
|
while (*readptr == '\r' || *readptr == '\n')
|
||||||
if (*readptr == 0) return NULL;
|
readptr++;
|
||||||
else return readptr;
|
if (*readptr == 0)
|
||||||
|
return NULL;
|
||||||
|
else
|
||||||
|
return readptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -559,10 +566,6 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
|
|||||||
wxInputStream *s;
|
wxInputStream *s;
|
||||||
wxString bookFull;
|
wxString bookFull;
|
||||||
|
|
||||||
int sz;
|
|
||||||
char *buff, *lineptr;
|
|
||||||
char linebuf[300];
|
|
||||||
|
|
||||||
wxString title = _("noname"),
|
wxString title = _("noname"),
|
||||||
safetitle,
|
safetitle,
|
||||||
start = wxEmptyString,
|
start = wxEmptyString,
|
||||||
@@ -588,25 +591,34 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
|
|||||||
}
|
}
|
||||||
fsys.ChangePathTo(bookFull);
|
fsys.ChangePathTo(bookFull);
|
||||||
s = fi->GetStream();
|
s = fi->GetStream();
|
||||||
|
|
||||||
|
int sz;
|
||||||
|
char *buff, *lineptr;
|
||||||
|
char linebuf[300];
|
||||||
|
|
||||||
sz = s->GetSize();
|
sz = s->GetSize();
|
||||||
buff = new char[sz + 1];
|
buff = new char[sz + 1];
|
||||||
buff[sz] = 0;
|
buff[sz] = 0;
|
||||||
s->Read(buff, sz);
|
s->Read(buff, sz);
|
||||||
lineptr = buff;
|
lineptr = buff;
|
||||||
|
|
||||||
do {
|
do
|
||||||
lineptr = ReadLine(lineptr, linebuf);
|
{
|
||||||
|
lineptr = ReadLine(lineptr, linebuf, 300);
|
||||||
|
|
||||||
if (strstr(linebuf, "Title=") == linebuf)
|
for (char *ch = linebuf; *ch != '\0' && *ch != '='; ch++)
|
||||||
title = linebuf + strlen("Title=");
|
*ch = tolower(*ch);
|
||||||
if (strstr(linebuf, "Default topic=") == linebuf)
|
|
||||||
start = linebuf + strlen("Default topic=");
|
if (strstr(linebuf, "title=") == linebuf)
|
||||||
if (strstr(linebuf, "Index file=") == linebuf)
|
title = linebuf + strlen("title=");
|
||||||
index = linebuf + strlen("Index file=");
|
if (strstr(linebuf, "default topic=") == linebuf)
|
||||||
if (strstr(linebuf, "Contents file=") == linebuf)
|
start = linebuf + strlen("default topic=");
|
||||||
contents = linebuf + strlen("Contents file=");
|
if (strstr(linebuf, "index file=") == linebuf)
|
||||||
if (strstr(linebuf, "Charset=") == linebuf)
|
index = linebuf + strlen("index file=");
|
||||||
charset = linebuf + strlen("Charset=");
|
if (strstr(linebuf, "contents file=") == linebuf)
|
||||||
|
contents = linebuf + strlen("contents file=");
|
||||||
|
if (strstr(linebuf, "charset=") == linebuf)
|
||||||
|
charset = linebuf + strlen("charset=");
|
||||||
} while (lineptr != NULL);
|
} while (lineptr != NULL);
|
||||||
delete[] buff;
|
delete[] buff;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user