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
No related merge requests found
...@@ -1209,7 +1209,7 @@ void packmsgs(ulong packable) ...@@ -1209,7 +1209,7 @@ void packmsgs(ulong packable)
} }
else { else {
fseek(tmp_sdt,0L,SEEK_END); fseek(tmp_sdt,0L,SEEK_END);
offset=ftell(tmp_sdt); offset = ftello(tmp_sdt);
if(offset < 0) { if(offset < 0) {
fprintf(errfp,"\n%s!ftell() ERROR %d\n", beep, errno); fprintf(errfp,"\n%s!ftell() ERROR %d\n", beep, errno);
continue; continue;
...@@ -1235,10 +1235,15 @@ void packmsgs(ulong packable) ...@@ -1235,10 +1235,15 @@ void packmsgs(ulong packable)
/* Write the new index entry */ /* Write the new index entry */
length=smb_getmsghdrlen(&msg); length=smb_getmsghdrlen(&msg);
off_t offset;
if(smb.status.attr&SMB_HYPERALLOC) if(smb.status.attr&SMB_HYPERALLOC)
msg.idx.offset=ftell(tmp_shd); offset = ftello(tmp_shd);
else 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); smb_init_idx(&smb, &msg);
fseek(tmp_sid, l * idxreclen, SEEK_SET); fseek(tmp_sid, l * idxreclen, SEEK_SET);
fwrite(&msg.idx, 1, sizeof(msg.idx), tmp_sid); fwrite(&msg.idx, 1, sizeof(msg.idx), tmp_sid);
...@@ -1257,6 +1262,7 @@ void packmsgs(ulong packable) ...@@ -1257,6 +1262,7 @@ void packmsgs(ulong packable)
length++; length++;
} }
total++; total++;
}
smb_freemsgmem(&msg); smb_freemsgmem(&msg);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment