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

Fix CID 33252: Argument cannot be negative

parent cd20a33c
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -564,13 +564,20 @@ bool sbbs_t::guru_page(void) ...@@ -564,13 +564,20 @@ bool sbbs_t::guru_page(void)
errormsg(WHERE,ERR_OPEN,path,O_RDONLY); errormsg(WHERE,ERR_OPEN,path,O_RDONLY);
return(false); return(false);
} }
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) { long length = (long)filelength(file);
errormsg(WHERE,ERR_ALLOC,path,(size_t)filelength(file)+1); if(length < 0) {
errormsg(WHERE ,ERR_CHK, path, length);
close(file);
return false;
}
if((gurubuf=(char *)malloc(length + 1))==NULL) {
errormsg(WHERE, ERR_ALLOC, path, length + 1);
close(file); close(file);
return(false); return(false);
} }
(void)read(file,gurubuf,(size_t)filelength(file)); if(read(file,gurubuf,length) != length)
gurubuf[filelength(file)]=0; errormsg(WHERE, ERR_READ, path, length);
gurubuf[length]=0;
close(file); close(file);
localguru(gurubuf,i); localguru(gurubuf,i);
free(gurubuf); free(gurubuf);
......
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