Merge branch 'stb-image-fuzzing-fixes' of https://github.com/rcgordon/stb into working
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sean Barrett · committed by Sean Barrett · parents 58b2e14, c29138b · Browse files · 1 file·+129 added−42 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+129 added−42 removed
- other:+129 added−42 removed
Provenance
- Commit
bfaccab- Tree
3ae5e1f- Author
Sean Barrett <seanb@radgametools.com>- Committer
Sean Barrett <seanb@radgametools.com>- Parent 1
58b2e14- Parent 2
c29138b
1 file changed+129 added−42 removed
modified:stb_image.h+129 added-42 removed
91 unmodified lines92 John-Mark Allen93 Carmelo J Fdez-Aguera94 95 Bug & warning fixes96- Marc LeBlanc David Woo Guillaume George Martins Mozeiko97- Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan98- Dave Moore Roy Eltham Hayaki Saito Nathan Reed99- Won Chun Luke Graham Johan Duparc Nick Verigakis100- the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh101- Janez Zemva John Bartholomew Michal Cichon github:romigrou102- Jonathan Blow Ken Hamada Tero Hanninen github:svdijk103- Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar104- Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex105- Ryamond Barbiero Paul Du Bois Engin Manap github:grim210106- Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw107- Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus108- Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo109- Christian Floisand Kevin Schmidt JR Smith github:darealshinji110- Brad Weinberger Matvey Cherevko Luca Sas github:Michaelangel007111- Blazej Dariusz Roszkowski Alexander Veselov Zack Middleton96+ Marc LeBlanc David Woo Guillaume George Martins Mozeiko97+ Christpher Lloyd Jerry Jansson Joseph Thomson Blazej Dariusz Roszkowski98+ Phil Jordan Dave Moore Roy Eltham 99+ Hayaki Saito Nathan Reed Won Chun100+ Luke Graham Johan Duparc Nick Verigakis the Horde3D community 101+ Thomas Ruf Ronny Chevalier github:rlyeh 102+ Janez Zemva John Bartholomew Michal Cichon github:romigrou 103+ Jonathan Blow Ken Hamada Tero Hanninen github:svdijk 104+ Laurent Gomila Cort Stratton github:snagar 105+ Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex 106+ Cass Everitt Ryamond Barbiero github:grim210 107+ Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw 108+ Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus 109+ Josh Tobin Matthew Gregan github:poppolopoppo 110+ Julian Raschke Gregory Mullen Christian Floisand github:darealshinji 111+ Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007 112+ Brad Weinberger Matvey Cherevko [reserved]113+ Luca Sas Alexander Veselov Zack Middleton [reserved]114+ Ryan C. Gordon [reserved] [reserved]115+ DO NOT ADD YOUR NAME HERE 116+117+ To add your name to the credits, pick a random blank space in the middle and fill it.118+ 80% of merge conflicts on stb PRs are due to people adding their name at the end119+ of the credits.120 */121 122 #ifndef STBI_INCLUDE_STB_IMAGE_H123 #define STBI_INCLUDE_STB_IMAGE_H201 unmodified lines325 //326 // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still327 // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB328 //329+// - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater330+// than that size (in either width or height) without further processing.331+// This is to let programs in the wild set an upper bound to prevent332+// denial-of-service attacks on untrusted data, as one could generate a333+// valid image of gigantic dimensions and force stb_image to allocate a334+// huge block of memory and spend disproportionate time decoding it. By335+// default this is set to (1 << 24), which is 16777216, but that's still336+// very big.337 322-338 #ifndef STBI_NO_STDIO339 #include <stdio.h>340 #endif // STBI_NO_STDIO341 406 unmodified lines748 #ifndef STBI_SIMD_ALIGN749 #define STBI_SIMD_ALIGN(type, name) type name750 #endif751 752+#ifndef STBI_MAX_DIMENSIONS753+#define STBI_MAX_DIMENSIONS (1 << 24)754+#endif755+756 ///////////////////////////////////////////////757 //758 // stbi__context struct and start_xxx functions759 50 unmodified lines810 }811 812 static void stbi__stdio_skip(void *user, int n)813 {814+ int ch;815 fseek((FILE*) user, n, SEEK_CUR);816+ ch = fgetc((FILE*) user); /* have to read a byte to reset feof()'s flag */817+ if (ch != EOF) {818+ ungetc(ch, (FILE *) user); /* push byte back onto stream if valid. */819+ }820 }821 822 static int stbi__stdio_eof(void *user)823 {800- return feof((FILE*) user);824+ return feof((FILE*) user) || ferror((FILE *) user);825 }826 827 static stbi_io_callbacks stbi__stdio_callbacks =828 {368 unmodified lines1197 1198 if (result == NULL)1199 return NULL;1200 1201+ // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.1202+ STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);1203+1204 if (ri.bits_per_channel != 8) {1178- STBI_ASSERT(ri.bits_per_channel == 16);1205 result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);1206 ri.bits_per_channel = 8;1207 }1208 14 unmodified lines1223 1224 if (result == NULL)1225 return NULL;1226 1227+ // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.1228+ STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);1229+1230 if (ri.bits_per_channel != 16) {1202- STBI_ASSERT(ri.bits_per_channel == 8);1231 result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);1232 ri.bits_per_channel = 16;1233 }1234 340 unmodified lines1575 // nothing1576 #else1577 static void stbi__skip(stbi__context *s, int n)1578 {1579+ if (n == 0) return; // already there!1580 if (n < 0) {1581 s->img_buffer = s->img_buffer_end;1582 return;1583 }134 unmodified lines1718 STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break;1719 STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break;1720 STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;1721 STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break;1693- default: STBI_ASSERT(0);1722+ default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion");1723 }1724 #undef STBI__CASE1725 }1726 48 unmodified lines1775 STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break;1776 STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break;1777 STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break;1778 STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break;1750- default: STBI_ASSERT(0);1779+ default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion");1780 }1781 #undef STBI__CASE1782 }1783 300 unmodified lines2084 if (j->code_bits < n) stbi__grow_buffer_unsafe(j);2085 2086 sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB2087 k = stbi_lrot(j->code_buffer, n);2059- STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask)));2088+ if (n < 0 || n >= (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))) return 0;2089 j->code_buffer = k & ~stbi__bmask[n];2090 k &= stbi__bmask[n];2091 j->code_bits -= n;2092 return k + (stbi__jbias[n] & ~sgn);102 unmodified lines2195 if (j->succ_high == 0) {2196 // first scan for DC coefficient, must be first2197 memset(data,0,64*sizeof(data[0])); // 0 all the ac values now2198 t = stbi__jpeg_huff_decode(j, hdc);2199+ if (t == -1) return stbi__err("can't merge dc and ac", "Corrupt JPEG");2200 diff = t ? stbi__extend_receive(j, t) : 0;2201 2202 dc = j->img_comp[b].dc_pred + diff;2203 j->img_comp[b].dc_pred = dc;982 unmodified lines3186 Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG3187 p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline3188 s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG3189 s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires3190+ if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");3191+ if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");3192 c = stbi__get8(s);3193 if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG");3194 s->img_n = c;3195 for (i=0; i < c; ++i) {872 unmodified lines4068 4069 stbi__zhuffman z_length, z_distance;4070 } stbi__zbuf;4071 4072+stbi_inline static int stbi__zeof(stbi__zbuf *z)4073+{4074+ return (z->zbuffer >= z->zbuffer_end);4075+}4076+4077 stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z)4078 {4042- if (z->zbuffer >= z->zbuffer_end) return 0;4043- return *z->zbuffer++;4079+ return stbi__zeof(z) ? 0 : *z->zbuffer++;4080 }4081 4082 static void stbi__fill_bits(stbi__zbuf *z)4083 {4084 do {4049- STBI_ASSERT(z->code_buffer < (1U << z->num_bits));4085+ if (z->code_buffer >= (1U << z->num_bits)) {4086+ z->zbuffer = z->zbuffer_end; /* treat this as EOF so we fail. */4087+ return;4088+ }4089 z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits;4090 z->num_bits += 8;4091 } while (z->num_bits <= 24);4092 }16 unmodified lines4109 k = stbi__bit_reverse(a->code_buffer, 16);4110 for (s=STBI__ZFAST_BITS+1; ; ++s)4111 if (k < z->maxcode[s])4112 break;4074- if (s == 16) return -1; // invalid code!4113+ if (s >= 16) return -1; // invalid code!4114 // code size is s, so:4115 b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];4077- STBI_ASSERT(z->size[b] == s);4116+ if (b >= sizeof (z->size)) return -1; // some data was corrupt somewhere!4117+ if (z->size[b] != s) return -1; // was originally an assert, but report failure instead.4118 a->code_buffer >>= s;4119 a->num_bits -= s;4120 return z->value[b];4121 }4122 4123 stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)4124 {4125 int b,s;4086- if (a->num_bits < 16) stbi__fill_bits(a);4126+ if (a->num_bits < 16) {4127+ if (stbi__zeof(a)) {4128+ return -1; /* report error for unexpected end of data. */4129+ }4130+ stbi__fill_bits(a);4131+ }4132 b = z->fast[a->code_buffer & STBI__ZFAST_MASK];4133 if (b) {4134 s = b >> 9;4135 a->code_buffer >>= s;5 unmodified lines4141 4142 static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes4143 {4144 char *q;4100- int cur, limit, old_limit;4145+ unsigned int cur, limit, old_limit;4146 z->zout = zout;4147 if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG");4103- cur = (int) (z->zout - z->zout_start);4104- limit = old_limit = (int) (z->zout_end - z->zout_start);4105- while (cur + n > limit)4148+ cur = (unsigned int) (z->zout - z->zout_start);4149+ limit = old_limit = (unsigned) (z->zout_end - z->zout_start);4150+ if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory");4151+ while (cur + n > limit) {4152+ if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory");4153 limit *= 2;4154+ }4155 q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);4156 STBI_NOTUSED(old_limit);4157 if (q == NULL) return stbi__err("outofmem", "Out of memory");4158 z->zout_start = q;89 unmodified lines4248 if (c == 16) {4249 c = stbi__zreceive(a,2)+3;4250 if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG");4251 fill = lencodes[n-1];4204- } else if (c == 17)4252+ } else if (c == 17) {4253 c = stbi__zreceive(a,3)+3;4206- else {4207- STBI_ASSERT(c == 18);4254+ } else if (c == 18) {4255 c = stbi__zreceive(a,7)+11;4256+ } else {4257+ return stbi__err("bad codelengths", "Corrupt PNG");4258 }4259 if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG");4260 memset(lencodes+n, fill, c);4261 n += c;17 unmodified lines4279 header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check4280 a->code_buffer >>= 8;4281 a->num_bits -= 8;4282 }4234- STBI_ASSERT(a->num_bits == 0);4283+ if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG");4284 // now fill header the normal way4285 while (k < 4)4286 header[k++] = stbi__zget8(a);4287 len = header[1] * 256 + header[0];13 unmodified lines4301 int cmf = stbi__zget8(a);4302 int cm = cmf & 15;4303 /* int cinfo = cmf >> 4; */4304 int flg = stbi__zget8(a);4305+ if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec4306 if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec4307 if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png4308 if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png4309 // window = 1 << (8 + cinfo)... but who cares, we fully buffer output253 unmodified lines4563 if (filter > 4)4564 return stbi__err("invalid filter","Corrupt PNG");4565 4566 if (depth < 8) {4517- STBI_ASSERT(img_width_bytes <= x);4567+ if (img_width_bytes > x) return stbi__err("invalid width","Corrupt PNG");4568 cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place4569 filter_bytes = 1;4570 width = img_width_bytes;4571 }386 unmodified lines4958 int comp,filter;4959 if (!first) return stbi__err("multiple IHDR","Corrupt PNG");4960 first = 0;4961 if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG");4912- s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)");4913- s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)");4962+ s->img_x = stbi__get32be(s);4963+ s->img_y = stbi__get32be(s);4964+ if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");4965+ if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");4966 z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only");4967 color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG");4968 if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG");4969 if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG");140 unmodified lines5110 {5111 void *result=NULL;5112 if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");5113 if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {5062- if (p->depth < 8)5114+ if (p->depth <= 8)5115 ri->bits_per_channel = 8;5116+ else if (p->depth == 16)5117+ ri->bits_per_channel = 16;5118 else5065- ri->bits_per_channel = p->depth;5119+ return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth");5120 result = p->out;5121 p->out = NULL;5122 if (req_comp && req_comp != p->s->img_out_n) {5123 if (ri->bits_per_channel == 8)152 unmodified lines5276 info->hsz = hsz = stbi__get32le(s);5277 info->mr = info->mg = info->mb = info->ma = 0;5278 info->extra_read = 14;5279 5280+ if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP");5281+5282 if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown");5283 if (hsz == 12) {5284 s->img_x = stbi__get16le(s);5285 s->img_y = stbi__get16le(s);83 unmodified lines5369 5370 flip_vertically = ((int) s->img_y) > 0;5371 s->img_y = abs((int) s->img_y);5372 5373+ if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5374+ if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5375+5376 mr = info.mr;5377 mg = info.mg;5378 mb = info.mb;5379 ma = info.ma;7 unmodified lines5387 psize = (info.offset - info.extra_read - info.hsz) >> 2;5388 }5389 if (psize == 0) {5390 STBI_ASSERT(info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original));5391+ if (info.offset != s->callback_already_read + (s->img_buffer - s->buffer_start)) {5392+ return stbi__errpuc("bad offset", "Corrupt BMP");5393+ }5394 }5395 5396 if (info.bpp == 24 && ma == 0xff000000)5397 s->img_n = 3;86 unmodified lines5484 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr);5485 gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg);5486 bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb);5487 ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma);5488+ if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }5489 }5490 for (j=0; j < (int) s->img_y; ++j) {5491 if (easy) {5492 for (i=0; i < (int) s->img_x; ++i) {216 unmodified lines5709 STBI_NOTUSED(ri);5710 STBI_NOTUSED(tga_x_origin); // @TODO5711 STBI_NOTUSED(tga_y_origin); // @TODO5712 5713+ if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5714+ if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5715+5716 // do a tiny bit of precessing5717 if ( tga_image_type >= 8 )5718 {5719 tga_image_type -= 8;31 unmodified lines5751 } else {5752 // do I need to load a palette?5753 if ( tga_indexed)5754 {5755+ if (tga_palette_len == 0) { /* you have to have at least one entry! */5756+ STBI_FREE(tga_data);5757+ return stbi__errpuc("bad palette", "Corrupt TGA");5758+ }5759+5760 // any data to skip? (offset usually = 0)5761 stbi__skip(s, tga_palette_start );5762 // load the palette5763 tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0);200 unmodified lines5964 // Read the rows and columns of the image.5965 h = stbi__get32be(s);5966 w = stbi__get32be(s);5967 5968+ if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5969+ if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");5970+5971 // Make sure the depth is 8 bits.5972 bitdepth = stbi__get16be(s);5973 if (bitdepth != 8 && bitdepth != 16)5974 return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");346 unmodified lines6321 stbi__get8(s);6322 6323 x = stbi__get16be(s);6324 y = stbi__get16be(s);6325+6326+ if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");6327+ if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");6328+6329 if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)");6330 if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode");6331 6332 stbi__get32be(s); //skip `ratio'100 unmodified lines6433 g->bgindex = stbi__get8(s);6434 g->ratio = stbi__get8(s);6435 g->transparent = -1;6436 6437+ if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");6438+ if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");6439+6440 if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments6441 6442 if (is_info) return 1;6443 541 unmodified lines6985 if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format");6986 token += 3;6987 width = (int) strtol(token, NULL, 10);6988 6989+ if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");6990+ if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");6991+6992 *x = width;6993 *y = height;6994 6995 if (comp) *comp = 3;306 unmodified lines7302 7303 if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n))7304 return 0;7305 7306+ if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");7307+ if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");7308+7309 *x = s->img_x;7310 *y = s->img_y;7311 if (comp) *comp = s->img_n;7312 443 unmodified lines