Skip to content
Snippets Groups Projects
Commit 25af5ed9 authored by rswindell's avatar rswindell
Browse files

Two fixes to smb_freemsgdat(): doesn't do anything if msgbase uses

hyper allocation method (allocation files aren't used) and closes allocation
file (if opened) on error.
parent 4c273519
No related branches found
No related tags found
No related merge requests found
...@@ -1368,9 +1368,13 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length ...@@ -1368,9 +1368,13 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length
, ushort headers) , ushort headers)
{ {
int da_opened=0; int da_opened=0;
int retval=0;
ushort i; ushort i;
ulong l,blocks; ulong l,blocks;
if(smb->status.attr&SMB_HYPERALLOC) /* do nothing */
return(0);
blocks=smb_datblocks(length); blocks=smb_datblocks(length);
if(smb->sda_fp==NULL) { if(smb->sda_fp==NULL) {
...@@ -1385,11 +1389,13 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length ...@@ -1385,11 +1389,13 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length
sprintf(smb->last_error sprintf(smb->last_error
,"seeking to %ld of allocation file" ,"seeking to %ld of allocation file"
,((offset/SDT_BLOCK_LEN)+l)*2L); ,((offset/SDT_BLOCK_LEN)+l)*2L);
return(1); retval=1;
break;
} }
if(!fread(&i,2,1,smb->sda_fp)) { if(!fread(&i,2,1,smb->sda_fp)) {
sprintf(smb->last_error,"reading allocation bytes"); sprintf(smb->last_error,"reading allocation bytes");
return(2); retval=2;
break;
} }
if(!headers || headers>i) if(!headers || headers>i)
i=0; /* don't want to go negative */ i=0; /* don't want to go negative */
...@@ -1397,17 +1403,19 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length ...@@ -1397,17 +1403,19 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length
i-=headers; i-=headers;
if(fseek(smb->sda_fp,-2L,SEEK_CUR)) { if(fseek(smb->sda_fp,-2L,SEEK_CUR)) {
sprintf(smb->last_error,"seeking backwards 2 bytes in allocation file"); sprintf(smb->last_error,"seeking backwards 2 bytes in allocation file");
return(3); retval=3;
break;
} }
if(!fwrite(&i,2,1,smb->sda_fp)) { if(!fwrite(&i,2,1,smb->sda_fp)) {
sprintf(smb->last_error,"writing allocation bytes"); sprintf(smb->last_error,"writing allocation bytes");
return(4); retval=4;
break;
} }
} }
fflush(smb->sda_fp); fflush(smb->sda_fp);
if(da_opened) if(da_opened)
smb_close_da(smb); smb_close_da(smb);
return(0); return(retval);
} }
/****************************************************************************/ /****************************************************************************/
......
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