- Timestamp:
- Apr 13, 2006, 7:57:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/font.c
r763 r768 121 121 } 122 122 123 if(size < sizeof(struct font_header)) 124 return NULL; 125 123 126 f = malloc(sizeof(struct cucul_font)); 124 127 f->private = (void *)(uintptr_t)data; … … 135 138 f->header.flags = htons(f->header.flags); 136 139 140 if(size != 8 + f->header.control_size + f->header.data_size 141 || (f->header.bpp != 8 && f->header.bpp != 4 && 142 f->header.bpp != 2 && f->header.bpp != 1)) 143 { 144 free(f); 145 return NULL; 146 } 147 137 148 f->block_list = malloc(f->header.blocks * sizeof(struct block_info)); 138 149 memcpy(f->block_list, … … 144 155 f->block_list[i].stop = htonl(f->block_list[i].stop); 145 156 f->block_list[i].index = htonl(f->block_list[i].index); 157 158 if(f->block_list[i].start > f->block_list[i].stop 159 || (i > 0 && f->block_list[i].start < f->block_list[i - 1].stop) 160 || f->block_list[i].index >= f->header.glyphs) 161 { 162 free(f->block_list); 163 free(f); 164 return NULL; 165 } 146 166 } 147 167 … … 156 176 f->glyph_list[i].height = htons(f->glyph_list[i].height); 157 177 f->glyph_list[i].data_offset = htonl(f->glyph_list[i].data_offset); 178 179 if(f->glyph_list[i].data_offset >= f->header.data_size 180 || f->glyph_list[i].data_offset 181 + f->glyph_list[i].width * f->glyph_list[i].height * 182 f->header.bpp / 8 >= f->header.data_size) 183 { 184 free(f->glyph_list); 185 free(f->block_list); 186 free(f); 187 return NULL; 188 } 158 189 } 159 190
Note: See TracChangeset
for help on using the changeset viewer.