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

Fix potential NULL deref in editfiledesc()

If the file doesn't already have a description, f->desc may be NULL.
Remove the redundant user name in the "removed file" log message.
parent 26c52535
No related branches found
No related tags found
No related merge requests found
......@@ -228,8 +228,7 @@ bool sbbs_t::removefile(smb_t* smb, file_t* f)
int result;
if((result = smb_removefile(smb ,f)) == SMB_SUCCESS) {
SAFEPRINTF4(str,"%s removed %s from %s %s"
,useron.alias
SAFEPRINTF3(str,"removed %s from %s %s"
,f->name
,cfg.lib[cfg.dir[smb->dirnum]->lib]->sname,cfg.dir[smb->dirnum]->sname);
logline("U-",str);
......@@ -252,7 +251,7 @@ bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir)
if(!addfile(&cfg, newdir, f, f->extdesc, /* client: */NULL))
return false;
if(!removefile(smb, &orgfile))
if(!removefile(smb, &orgfile)) // Use ::removefile() here instead?
return false;
bprintf(text[MovedFile],f->name
,cfg.lib[cfg.dir[newdir]->lib]->sname,cfg.dir[newdir]->sname);
......@@ -308,12 +307,13 @@ bool sbbs_t::editfiledesc(file_t* f)
{
// Description
bputs(text[EditDescription]);
char fdesc[LEN_FDESC + 1];
SAFECOPY(fdesc, f->desc);
char fdesc[LEN_FDESC + 1] = "";
if(f->desc != NULL)
SAFECOPY(fdesc, f->desc);
getstr(fdesc, sizeof(fdesc)-1, K_LINE|K_EDIT|K_AUTODEL|K_TRIM);
if(msgabort(true))
return false;
if(strcmp(fdesc, f->desc) == 0)
if(f->desc != NULL && strcmp(fdesc, f->desc) == 0)
return true;
smb_new_hfield_str(f, SMB_FILEDESC, fdesc);
return updatefile(&cfg, f);
......
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