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)
errormsg(WHERE,ERR_OPEN,path,O_RDONLY);
return(false);
}
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) {
errormsg(WHERE,ERR_ALLOC,path,(size_t)filelength(file)+1);
long length = (long)filelength(file);
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);
return(false);
}
(void)read(file,gurubuf,(size_t)filelength(file));
gurubuf[filelength(file)]=0;
if(read(file,gurubuf,length) != length)
errormsg(WHERE, ERR_READ, path, length);
gurubuf[length]=0;
close(file);
localguru(gurubuf,i);
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