Skip to content
Snippets Groups Projects
Commit 45872a4e authored by rswindell's avatar rswindell
Browse files

delmail() re-writes the mail.sid file. Since I've seen some recent

mail.sid corruption approximately around midnight (when delmail()) is
called as part of the "DAILY:" mail maintenance, I'm suspicious of this
function and while I haven't found any bugs, I did find (and now fixed)
lack of error checking in calls to smb_fsetlength() and smb_fwrite().
parent 8659b7ae
No related branches found
No related tags found
No related merge requests found
......@@ -113,13 +113,20 @@ int sbbs_t::delmail(uint usernumber, int which)
l++;
}
smb_rewind(smb.sid_fp);
smb_fsetlength(smb.sid_fp,0);
for(i=0;i<l;i++)
smb_fwrite(&smb,&idxbuf[i],sizeof(idxrec_t),smb.sid_fp);
if(smb_fsetlength(smb.sid_fp,0) != 0)
errormsg(WHERE, "truncating", smb.file, 0);
else {
for(i=0;i<l;i++) {
if(smb_fwrite(&smb,&idxbuf[i],sizeof(idxrec_t),smb.sid_fp) != sizeof(idxrec_t)) {
errormsg(WHERE, ERR_WRITE, smb.file, i);
break;
}
}
smb.status.total_msgs=i;
smb_putstatus(&smb);
smb_fflush(smb.sid_fp);
}
free(idxbuf);
smb.status.total_msgs=l;
smb_putstatus(&smb);
smb_fflush(smb.sid_fp);
smb_close_ha(&smb);
smb_close_da(&smb);
return removed;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment