Commit d2aab408 authored by rswindell's avatar rswindell
Browse files

fgets() only reads size-1, so sizeof(buf) is correct.

parent 498f3a19
......@@ -206,7 +206,7 @@ int sbbs_t::protocol(char *cmdline, bool cd)
// Save DSZLOG to logfile
if((stream=fnopen(NULL,protlog,O_RDONLY))!=NULL) {
while(!feof(stream) && !ferror(stream)) {
if(!fgets(protlog,sizeof(protlog)-1,stream))
if(!fgets(protlog,sizeof(protlog),stream))
break;
truncsp(protlog);
logline(nulstr,protlog);
......
......@@ -791,7 +791,7 @@ BOOL js_generate_index(JSContext* js_cx, JSObject* parent,
if((alias_fp=fopen(path,"r"))!=NULL) {
while(!feof(alias_fp)) {
if(!fgets(aliasline,sizeof(aliasline)-1,alias_fp))
if(!fgets(aliasline,sizeof(aliasline),alias_fp))
break;
p=aliasline; /* alias pointer */
......@@ -1174,7 +1174,7 @@ int sockreadline(SOCKET socket, char* buf, int len, time_t* lastactive)
/*****************************************************************************/
/* Returns command line generated from instr with %c replacments */
/*****************************************************************************/
char * cmdstr(user_t* user, char *instr, char *fpath, char *fspec, char *cmd)
static char* cmdstr(user_t* user, char *instr, char *fpath, char *fspec, char *cmd)
{
char str[256];
int i,j,len;
......@@ -2105,7 +2105,7 @@ static BOOL ftpalias(char* fullalias, char* filename, user_t* user, int* curdir)
return(FALSE);
while(!feof(fp)) {
if(!fgets(line,sizeof(line)-1,fp))
if(!fgets(line,sizeof(line),fp))
break;
p=line; /* alias */
......@@ -3254,7 +3254,7 @@ static void ctrl_thread(void* arg)
if((alias_fp=fopen(aliasfile,"r"))!=NULL) {
while(!feof(alias_fp)) {
if(!fgets(aliasline,sizeof(aliasline)-1,alias_fp))
if(!fgets(aliasline,sizeof(aliasline),alias_fp))
break;
alias_dir=FALSE;
......@@ -3573,7 +3573,7 @@ static void ctrl_thread(void* arg)
if((alias_fp=fopen(aliasfile,"r"))!=NULL) {
while(!feof(alias_fp)) {
if(!fgets(aliasline,sizeof(aliasline)-1,alias_fp))
if(!fgets(aliasline,sizeof(aliasline),alias_fp))
break;
p=aliasline; /* alias pointer */
......
......@@ -915,7 +915,7 @@ int main(int argc, char** argv)
if((fp=fopen("/etc/resolv.conf","r"))!=NULL) {
while(!feof(fp)) {
if(fgets(str,sizeof(str)-1,fp)==NULL)
if(fgets(str,sizeof(str),fp)==NULL)
break;
truncsp(str);
p=str;
......@@ -1440,7 +1440,7 @@ int main(int argc, char** argv)
case 'd': /* down node */
case 'i': /* interrupt node */
printf("\nNode number: ");
if((n=atoi(fgets(str,sizeof(str)-1,stdin)))<1)
if((n=atoi(fgets(str,sizeof(str),stdin)))<1)
break;
fflush(stdin);
printf("\n");
......
......@@ -1148,7 +1148,7 @@ static service_t* read_services_cfg(char* services_cfg, DWORD* services)
}
for((*services)=0;!feof(fp) && (*services)<MAX_SERVICES;) {
if(!fgets(line,sizeof(line)-1,fp))
if(!fgets(line,sizeof(line),fp))
break;
p=line;
while(*p && *p<=' ') p++;
......
......@@ -73,7 +73,7 @@ char compiler[32];
#endif
/* gets is dangerous */
#define gets(str) fgets((str), sizeof(str) - 1, stdin)
#define gets(str) fgets((str), sizeof(str), stdin)
/********************/
/* Global variables */
......@@ -216,7 +216,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
if(to==NULL) {
printf("To User Name: ");
fgets(str,sizeof(str)-1,stdin);
fgets(str,sizeof(str),stdin);
} else
SAFECOPY(str,to);
......
......@@ -102,7 +102,7 @@ int DLLCALL set_socket_options(scfg_t* cfg, SOCKET sock, char* error)
}
while(!feof(fp)) {
if(!fgets(str,sizeof(str)-1,fp))
if(!fgets(str,sizeof(str),fp))
break;
if(str[0]==';')
continue;
......
......@@ -409,7 +409,7 @@ bool sbbs_t::writemsg(char *fname, char *top, char *title, long mode, int subnum
FILE* sig;
if(fexist(str) && (sig=fopen(str,"rb"))!=NULL) {
while(!feof(sig)) {
if(!fgets(str,sizeof(str)-1,sig))
if(!fgets(str,sizeof(str),sig))
break;
fputs(str,stream);
l+=strlen(str); /* byte counter */
......
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