Skip to content
Snippets Groups Projects
Commit 9169e4aa authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Detect/report smb_fallochdr() and ftell() failures

Fix CID 33244: Argument cannot be negative
parent ecce2a8a
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -1209,7 +1209,7 @@ void packmsgs(ulong packable)
}
else {
fseek(tmp_sdt,0L,SEEK_END);
offset=ftell(tmp_sdt);
offset = ftello(tmp_sdt);
if(offset < 0) {
fprintf(errfp,"\n%s!ftell() ERROR %d\n", beep, errno);
continue;
......@@ -1235,10 +1235,15 @@ void packmsgs(ulong packable)
/* Write the new index entry */
length=smb_getmsghdrlen(&msg);
off_t offset;
if(smb.status.attr&SMB_HYPERALLOC)
msg.idx.offset=ftell(tmp_shd);
offset = ftello(tmp_shd);
else
msg.idx.offset=(uint32_t)smb_fallochdr(&smb,(ulong)length)+smb.status.header_offset;
offset = smb_fallochdr(&smb,(ulong)length)+smb.status.header_offset;
if(offset < 0) {
fprintf(errfp,"\n%s!header allocation ERROR %ld\n", beep, (long)offset);
} else {
msg.idx.offset = (uint32_t)offset;
smb_init_idx(&smb, &msg);
fseek(tmp_sid, l * idxreclen, SEEK_SET);
fwrite(&msg.idx, 1, sizeof(msg.idx), tmp_sid);
......@@ -1257,6 +1262,7 @@ void packmsgs(ulong packable)
length++;
}
total++;
}
smb_freemsgmem(&msg);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment