remove_tail(dbuf, cur_len);
cur_len = len - cur_len;
- if (cur_len && !dbuf->cur)
+ if (cur_len < 0 || !dbuf->cur)
return 1;
memcpy(dest, dbuf->cur + dbuf->cur_len - cur_len, cur_len);
while (1) {
- if (extract_tail(&dbuf, &tr, sizeof(tr)))
+ if (extract_tail(&dbuf, &tr, sizeof(tr))) {
+ msg("unable to extract trailer header\n");
break;
+ }
if (tr.magic != cpu_to_be32(FWIMAGE_MAGIC)) {
msg("Data not found\n");
break;
}
- extract_tail(&dbuf, buf, data_len);
+ if (extract_tail(&dbuf, buf, data_len)) {
+ msg("unable to extract trailer data\n");
+ break;
+ }
if (tr.type == FWIMAGE_SIGNATURE) {
if (!signature_file)