return(toupper((int) *p)-toupper((int) *q));
}
-static int convertHTMLcodes(char *s, int len)
+static size_t convertHTMLcodes(char *s, const size_t len)
{
- if (len <=0 || s==(char*) NULL || *s=='\0')
- return 0;
+ int
+ value;
- if (s[1] == '#')
+ if ((len == 0) || (s == (char*) NULL) || (*s=='\0'))
+ return(0);
+ if ((len > 3) && (s[1] == '#') && (strchr(s,';') != (char *) NULL) &&
+ (sscanf(s,"&#%d;",&value) == 1))
{
- int val, o;
-
- if (sscanf(s,"&#%d;",&val) == 1)
+ size_t o = 3;
+ while (s[o] != ';')
{
- o = 3;
- while (s[o] != ';')
- {
- o++;
- if (o > 5)
- break;
- }
- if (o < 6)
- (void) memmove(s+1,s+1+o,strlen(s+1+o)+1);
- *s = val;
- return o;
+ o++;
+ if (o > 5)
+ break;
}
+ if (o < 6)
+ (void) memmove(s+1,s+1+o,strlen(s+1+o)+1);
+ *s=value;
+ return(o);
}
else
{
int
i,
- codes = (int) (sizeof(html_codes) / sizeof(html_code));
+ codes;
+ codes=sizeof(html_codes)/sizeof(html_code);
for (i=0; i < codes; i++)
{
if (html_codes[i].len <= len)
- if (stringnicmp(s,html_codes[i].code,(size_t) html_codes[i].len) == 0)
+ if (stringnicmp(s, html_codes[i].code,(size_t) (html_codes[i].len)) == 0)
{
(void) memmove(s+1,s+html_codes[i].len,
strlen(s+html_codes[i].len)+1);
*s=html_codes[i].val;
- return html_codes[i].len-1;
+ return(html_codes[i].len-1);
}
}
}
- return 0;
+ return(0);
}
static char *super_fgets(char **b, int *blen, Image *file)
char
*s = &token[next-1];
- len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));
+ len -= (ssize_t) convertHTMLcodes(s,strlen(s));
}
}
char
*s = &token[next-1];
- len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));
+ len -= (ssize_t) convertHTMLcodes(s,strlen(s));
}
}
image->rows*sizeof(*runlength));
if (runlength == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- buffer=(unsigned char *) AcquireQuantumMemory(257,sizeof(*buffer));
+ buffer=(unsigned char *) AcquireQuantumMemory(512,sizeof(*buffer));
if (buffer == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
packet_size=(size_t) (image->depth > 8 ? 2: 1);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
one=1;
map_length=one << map_length;
- if ((number_planes == 0) || (number_planes == 2) || (bits_per_pixel != 8) ||
+ if ((number_planes == 0) || (number_planes == 2) ||
+ ((flags & 0x04) && (number_colors > 254)) || (bits_per_pixel != 8) ||
(image->columns == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (flags & 0x02)