Skip to content
Snippets Groups Projects
Commit 8659b7ae authored by rswindell's avatar rswindell
Browse files

smb_addmsghdr() will now confirm the index file length against the

status.total_msgs value: if they don't match, don't add header & index
to the message base, it's apparently corrupted and we're only going to
make things worse as smb_putmsgidx() will fail (after we've stored the hdr)
with an "invalid index offset" error.
parent 8bb58267
No related branches found
No related tags found
No related merge requests found
......@@ -1529,6 +1529,7 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
int i;
long l;
ulong hdrlen;
long idxlen;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
......@@ -1551,6 +1552,16 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
smb_unlocksmbhdr(smb);
return(i);
}
idxlen = filelength(fileno(smb->sid_fp));
if(idxlen != (smb->status.total_msgs * sizeof(idxrec_t))) {
safe_snprintf(smb->last_error, sizeof(smb->last_error)
,"%s index file length (%ld) unexpected (%ld)", __FUNCTION__
,idxlen, smb->status.total_msgs * sizeof(idxrec_t));
smb_unlocksmbhdr(smb);
return SMB_ERR_FILE_LEN;
}
msg->hdr.number=smb->status.last_msg+1;
if(msg->hdr.thread_id==0) /* new thread being started */
......
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