| 1194 | } |
| 1195 | |
| 1196 | static unsigned inflateNoCompression(ucvector* out, const unsigned char* in, size_t* bp, size_t* pos, size_t inlength) |
| 1197 | { |
| 1198 | /*go to first boundary of byte*/ |
| 1199 | size_t p; |
| 1200 | unsigned LEN, NLEN, n, error = 0; |
| 1201 | while(((*bp) & 0x7) != 0) (*bp)++; |
| 1202 | p = (*bp) / 8; /*byte position*/ |
| 1203 | |
| 1204 | /*read LEN (2 bytes) and NLEN (2 bytes)*/ |
| 1205 | if(p >= inlength - 4) return 52; /*error, bit pointer will jump past memory*/ |
| 1206 | LEN = in[p] + 256u * in[p + 1]; p += 2; |
| 1207 | NLEN = in[p] + 256u * in[p + 1]; p += 2; |
| 1208 | |
| 1209 | /*check if 16-bit NLEN is really the one's complement of LEN*/ |
| 1210 | if(LEN + NLEN != 65535) return 21; /*error: NLEN is not one's complement of LEN*/ |
| 1211 | |
| 1212 | if(!ucvector_resize(out, (*pos) + LEN)) return 83; /*alloc fail*/ |
| 1213 | |
| 1214 | /*read the literal data: LEN bytes are now stored in the out buffer*/ |
| 1215 | if(p + LEN > inlength) return 23; /*error: reading outside of in buffer*/ |
| 1216 | for(n = 0; n < LEN; n++) out->data[(*pos)++] = in[p++]; |
| 1217 | |
| 1218 | (*bp) = p * 8; |
| 1219 | |
| 1220 | return error; |
| 1221 | } |
| 1222 | |
| 1223 | static unsigned lodepng_inflatev(ucvector* out, |
| 1224 | const unsigned char* in, size_t insize, |
no test coverage detected