mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 23:30:48 +00:00
Avoid potential illegal access violation introduced with the previous
commit. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30775 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cf66de78fc
commit
958681e979
1 changed files with 19 additions and 13 deletions
|
@ -766,25 +766,31 @@ create_error(int code, NSString* desc)
|
||||||
|
|
||||||
if (type == nil)
|
if (type == nil)
|
||||||
{
|
{
|
||||||
const void *dataBytes = [data bytes];
|
// Make sure this buffer is long enough
|
||||||
|
char prefix[14];
|
||||||
|
NSUInteger l = [data length];
|
||||||
|
if (l < sizeof(prefix))
|
||||||
|
{
|
||||||
|
[data getBytes: prefix length: l];
|
||||||
|
prefix[l] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[data getBytes: prefix length: sizeof(prefix)];
|
||||||
|
}
|
||||||
|
|
||||||
// The list of file types below was derived from Apache's conf/magic file
|
// The list of file types below was derived from Apache's conf/magic file
|
||||||
// FIXME extend the list
|
// FIXME extend the list
|
||||||
if (strncmp(dataBytes, "{\\rtf", 5) == 0)
|
if (strncmp(prefix, "{\\rtf", 5) == 0)
|
||||||
{
|
{
|
||||||
type = NSRTFTextDocumentType;
|
type = NSRTFTextDocumentType;
|
||||||
}
|
}
|
||||||
else if (strncmp(dataBytes, "<!DOCTYPE HTML", 14) == 0 ||
|
else if (strncasecmp(prefix, "<!doctype html", 14) == 0 ||
|
||||||
strncmp(dataBytes, "<!doctype html", 14) == 0 ||
|
strncasecmp(prefix, "<head", 5) == 0 ||
|
||||||
strncmp(dataBytes, "<HEAD", 5) == 0 ||
|
strncasecmp(prefix, "<title", 6) == 0 ||
|
||||||
strncmp(dataBytes, "<head", 5) == 0 ||
|
strncasecmp(prefix, "<html", 5) == 0 ||
|
||||||
strncmp(dataBytes, "<TITLE", 6) == 0 ||
|
strncmp(prefix, "<!--", 4) == 0 ||
|
||||||
strncmp(dataBytes, "<title", 6) == 0 ||
|
strncasecmp(prefix, "<h1", 3) == 0)
|
||||||
strncmp(dataBytes, "<HTML", 5) == 0 ||
|
|
||||||
strncmp(dataBytes, "<html", 5) == 0 ||
|
|
||||||
strncmp(dataBytes, "<!--", 4) == 0 ||
|
|
||||||
strncmp(dataBytes, "<h1", 3) == 0 ||
|
|
||||||
strncmp(dataBytes, "<H1", 3) == 0)
|
|
||||||
{
|
{
|
||||||
type = NSHTMLTextDocumentType;
|
type = NSHTMLTextDocumentType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue