Commit b1bb5630 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Handle filelength() possibly returning negative value

CID 349724
parent aeecca16
Pipeline #2774 passed with stage
in 9 minutes and 18 seconds
...@@ -1457,7 +1457,7 @@ char* readsmsg(scfg_t* cfg, int usernumber) ...@@ -1457,7 +1457,7 @@ char* readsmsg(scfg_t* cfg, int usernumber)
if((file=nopen(str,O_RDWR))==-1) if((file=nopen(str,O_RDWR))==-1)
return(NULL); return(NULL);
length=(long)filelength(file); length=(long)filelength(file);
if((buf=(char *)malloc(length+1))==NULL) { if(length < 0 || (buf=(char *)malloc(length+1))==NULL) {
close(file); close(file);
return(NULL); return(NULL);
} }
......
Markdown is supported
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