Fix crash in rabin2 -g (thanks @condret)

This commit is contained in:
pancake 2014-09-26 17:30:20 +02:00
parent 8449eafe3d
commit b53eb9222d
1 changed files with 10 additions and 5 deletions

View File

@ -152,12 +152,17 @@ static int extract_binobj (const RBinFile *bf, const RBinObject *o, int idx ) {
snprintf (outfile, outfile_sz, "%s/%s.%s_%i.%d",
outpath, ptr, arch, bits, idx);
if (!outfile || !r_file_dump (outfile, bytes+boffset, bin_size)) {
eprintf ("Error extracting %s\n", outfile);
res = R_FALSE;
if (boffset > r_buf_size (bf->buf)) {
eprintf ("Invalid offsets\n");
res = R_FALSE;
} else {
printf ("%s created (%"PFMT64d")\n", outfile, bin_size);
res = R_TRUE;
if (!outfile || !r_file_dump (outfile, bytes+boffset, bin_size)) {
eprintf ("Error extracting %s\n", outfile);
res = R_FALSE;
} else {
printf ("%s created (%"PFMT64d")\n", outfile, bin_size);
res = R_TRUE;
}
}
free (outfile);