Commit 90bf6cd5 authored by Rob Swindell's avatar Rob Swindell 💬
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 83b8f43a
......@@ -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"
SAFEPRINTF3(str,"removed %s from %s %s"
......@@ -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;
......@@ -308,12 +307,13 @@ bool sbbs_t::editfiledesc(file_t* f)
// Description
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);
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);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment