Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 009e5883 authored by Rob Swindell's avatar Rob Swindell 💬

Address Coverity-reported issues.

parent 97d13513
Pipeline #1386 failed with stage
in 9 minutes and 57 seconds
/* js_com.c */
/* Synchronet JavaScript "COM" Object */
/* $Id: js_com.c,v 1.33 2020/04/20 01:47:45 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -169,7 +153,7 @@ js_send(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
char* cp = NULL;
size_t len;
size_t len = 0;
private_t* p;
jsrefcount rc;
......@@ -578,12 +562,13 @@ static JSBool js_com_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, j
p->last_error=i;
break;
case COM_PROP_BAUD_RATE:
JS_ValueToNumber(cx,*vp,&d);
p->baud_rate=(long)d;
rc=JS_SUSPENDREQUEST(cx);
if(p->is_open)
comSetBaudRate(p->com, p->baud_rate);
JS_RESUMEREQUEST(cx, rc);
if(JS_ValueToNumber(cx,*vp,&d)) {
p->baud_rate=(long)d;
rc=JS_SUSPENDREQUEST(cx);
if(p->is_open)
comSetBaudRate(p->com, p->baud_rate);
JS_RESUMEREQUEST(cx, rc);
}
break;
case COM_PROP_NETWORK_ORDER:
JS_ValueToBoolean(cx,*vp,&(p->network_byte_order));
......
......@@ -1761,11 +1761,11 @@ js_gotoxy(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(JSVAL_IS_OBJECT(argv[0])) {
JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"x", &val);
if(!JS_ValueToInt32(cx,val,&x))
if(!JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"x", &val)
|| !JS_ValueToInt32(cx,val,&x))
return JS_FALSE;
JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"y", &val);
if(!JS_ValueToInt32(cx,val,&y))
if(!JS_GetProperty(cx, JSVAL_TO_OBJECT(argv[0]),"y", &val)
|| !JS_ValueToInt32(cx,val,&y))
return JS_FALSE;
} else {
if((!JS_ValueToInt32(cx,argv[0],&x)) ||
......
......@@ -1533,7 +1533,10 @@ js_iniSetAllObjects(JSContext *cx, uintN argc, jsval *arglist)
continue;
}
/* value */
JS_GetProperty(cx,object,cp,&set_argv[2]);
if(!JS_GetProperty(cx,object,cp,&set_argv[2])) {
FREE_AND_NULL(cp);
continue;
}
FREE_AND_NULL(cp); /* Moved from before JS_GetProperty() call */
if(!js_iniSetValue_internal(cx,obj,3,set_argv,&list)) {
rval = JSVAL_FALSE;
......
......@@ -4194,12 +4194,13 @@ js_flags_str(JSContext *cx, uintN argc, jsval *arglist)
}
/* number to string */
JS_ValueToNumber(cx,argv[0],&d);
if(JS_ValueToNumber(cx,argv[0],&d)) {
if((js_str = JS_NewStringCopyZ(cx, ltoaf((long)d,str)))==NULL)
return(JS_FALSE);
if((js_str = JS_NewStringCopyZ(cx, ltoaf((long)d,str)))==NULL)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, STRING_TO_JSVAL(js_str));
JS_SET_RVAL(cx, arglist, STRING_TO_JSVAL(js_str));
}
return(JS_TRUE);
}
......
......@@ -554,9 +554,10 @@ void DLLCALL js_timeval(JSContext* cx, jsval val, struct timeval* tv)
if(JSVAL_IS_INT(val))
tv->tv_sec = JSVAL_TO_INT(val);
else if(JSVAL_IS_DOUBLE(val)) {
JS_ValueToNumber(cx,val,&jsd);
tv->tv_sec = (int)jsd;
tv->tv_usec = (int)(jsd*1000000.0)%1000000;
if(JS_ValueToNumber(cx,val,&jsd)) {
tv->tv_sec = (int)jsd;
tv->tv_usec = (int)(jsd*1000000.0)%1000000;
}
}
}
......@@ -840,7 +841,7 @@ js_send(JSContext *cx, uintN argc, jsval *arglist)
rc=JS_SUSPENDREQUEST(cx);
ret = js_socket_sendsocket(p,cp,len,TRUE);
if(ret >= 0) {
dbprintf(FALSE, p, "sent %d of %u bytes",ret,len);
dbprintf(FALSE, p, "sent %d of %lu bytes",ret,len);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(ret));
} else {
p->last_error=ERROR_VALUE;
......
......@@ -1106,7 +1106,8 @@ js_timestr(JSContext *cx, uintN argc, jsval *arglist)
if(argc<1)
ti=(jsdouble)time(NULL); /* use current time */
else
JS_ValueToNumber(cx,argv[0],&ti);
if(!JS_ValueToNumber(cx,argv[0],&ti))
return JS_TRUE;
rc=JS_SUSPENDREQUEST(cx);
timestr(sys->cfg,(time32_t)ti,str);
JS_RESUMEREQUEST(cx, rc);
......@@ -1440,8 +1441,10 @@ js_get_node(JSContext *cx, uintN argc, jsval *arglist)
scfg_t* cfg = sys->cfg;
node_num=cfg->node_num;
if(argc)
JS_ValueToInt32(cx,argv[0],&node_num);
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&node_num))
return JS_TRUE;
}
if(node_num<1)
node_num=1;
......@@ -1732,8 +1735,7 @@ js_new_user(JSContext *cx, uintN argc, jsval *arglist)
if(client!=NULL) {
if(client->protocol != NULL)
SAFECOPY(user.modem,client->protocol);
if(client->host != NULL)
SAFECOPY(user.comp,client->host);
SAFECOPY(user.comp,client->host);
if(client->addr != NULL)
SAFECOPY(user.ipaddr,client->addr);
}
......
......@@ -416,7 +416,7 @@ char* DLLCALL prep_dir(const char* base, char* path, size_t buflen)
else
SAFEPRINTF3(str,"%s%c%s",base,PATH_DELIM,path);
} else
strcpy(str,path);
SAFECOPY(str,path);
#ifdef __unix__ /* Change backslashes to forward slashes on Unix */
for(p=str;*p;p++)
......@@ -425,7 +425,7 @@ char* DLLCALL prep_dir(const char* base, char* path, size_t buflen)
#endif
backslashcolon(str);
strcat(str,"."); /* Change C: to C:. and C:\SBBS\ to C:\SBBS\. */
SAFECAT(str,"."); /* Change C: to C:. and C:\SBBS\ to C:\SBBS\. */
FULLPATH(abspath,str,buflen); /* Change C:\SBBS\NODE1\..\EXEC to C:\SBBS\EXEC */
backslash(abspath);
......
......@@ -2631,7 +2631,7 @@ static int chk_received_hdr(SOCKET socket,const char* prot,const char *buf,IN_AD
{
char host_name[128];
char *fromstr;
char ip[16];
char ip[16] = "ipv6-addr";
char *p;
char *p2;
char *last;
......
......@@ -3317,7 +3317,7 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
SAFECOPY(cfg.node_dir, cfg.node_path[node_num-1]);
prep_dir(cfg.node_dir, cfg.temp_dir, sizeof(cfg.temp_dir));
SAFEPRINTF2(syspage_semfile, "%ssyspage.%u", cfg.ctrl_dir, node_num);
remove(syspage_semfile);
(void)remove(syspage_semfile);
} else { /* event thread needs exclusive-use temp_dir */
if(startup->temp_dir[0])
SAFECOPY(cfg.temp_dir,startup->temp_dir);
......@@ -4077,7 +4077,7 @@ void sbbs_t::spymsg(const char* msg)
/****************************************************************************/
int sbbs_t::mv(char *src, char *dest, char copy)
{
char str[MAX_PATH+1],*buf,atr=curatr;
char *buf,atr=curatr;
int ind,outd;
uint chunk=MV_BUFLEN;
ulong length,l;
......@@ -4114,7 +4114,7 @@ int sbbs_t::mv(char *src, char *dest, char copy)
}
if((inp=fdopen(ind,"rb"))==NULL) {
close(ind);
errormsg(WHERE,ERR_FDOPEN,str,O_RDONLY);
errormsg(WHERE,ERR_FDOPEN,src,O_RDONLY);
return(-1);
}
setvbuf(inp,NULL,_IOFBF,32*1024);
......@@ -4391,7 +4391,7 @@ void sbbs_t::reset_logon_vars(void)
/****************************************************************************/
void sbbs_t::catsyslog(int crash)
{
char str[MAX_PATH+1];
char str[MAX_PATH+1] = "node.log";
char *buf;
int i,file;
long length;
......
......@@ -46,7 +46,7 @@ bool sbbs_t::printfile(const char* fname, long mode, long org_cols, JSObject* ob
FILE *stream;
SAFECOPY(fpath, fname);
fexistcase(fpath);
(void)fexistcase(fpath);
p=getfext(fpath);
if(p!=NULL) {
if(stricmp(p,".rip")==0) {
......@@ -171,7 +171,7 @@ bool sbbs_t::printtail(const char* fname, int lines, long mode, long org_cols, J
long length,l;
SAFECOPY(fpath, fname);
fexistcase(fpath);
(void)fexistcase(fpath);
if(mode&P_NOABORT) {
if(online==ON_REMOTE) {
rioctl(IOCM|ABORT);
......
......@@ -481,8 +481,8 @@ void status_thread(void *arg)
pthread_once(&init_once, init_lists);
startup->status(startup->cbdata, "Initializing");
strcpy(client.addr, startup->sock_fname);
strcpy(client.host, "<unix-domain>");
SAFECOPY(client.addr, startup->sock_fname);
SAFECOPY(client.host, "<unix-domain>");
client.protocol = "STATUS";
client.size = sizeof(client);
......
......@@ -336,26 +336,26 @@ echostat_msg_t fidomsg_to_echostat_msg(fmsghdr_t* hdr, fidoaddr_t* pkt_orig, con
return msg;
}
echostat_msg_t smsg_to_echostat_msg(smbmsg_t smsg, size_t msglen, fidoaddr_t addr)
echostat_msg_t smsg_to_echostat_msg(const smbmsg_t* smsg, size_t msglen, fidoaddr_t addr)
{
char* p;
echostat_msg_t emsg = {{0}};
SAFECOPY(emsg.to , smsg.to);
SAFECOPY(emsg.from , smsg.from);
SAFECOPY(emsg.subj , smsg.subj);
emsg.msg_time = smsg.hdr.when_written.time;
SAFECOPY(emsg.to , smsg->to);
SAFECOPY(emsg.from , smsg->from);
SAFECOPY(emsg.subj , smsg->subj);
emsg.msg_time = smsg->hdr.when_written.time;
emsg.localtime = time(NULL);
SAFECOPY(emsg.msg_tz, smb_zonestr(smsg.hdr.when_written.zone, NULL));
if(smsg.from_net.type == NET_FIDO && smsg.from_net.addr != NULL)
emsg.origaddr = *(fidoaddr_t*)smsg.from_net.addr;
if((p = smsg.ftn_msgid) != NULL)
SAFECOPY(emsg.msg_tz, smb_zonestr(smsg->hdr.when_written.zone, NULL));
if(smsg->from_net.type == NET_FIDO && smsg->from_net.addr != NULL)
emsg.origaddr = *(fidoaddr_t*)smsg->from_net.addr;
if((p = smsg->ftn_msgid) != NULL)
SAFECOPY(emsg.msg_id, p);
if((p = smsg.ftn_reply) != NULL)
if((p = smsg->ftn_reply) != NULL)
SAFECOPY(emsg.reply_id, p);
if((p = smsg.ftn_pid) != NULL)
if((p = smsg->ftn_pid) != NULL)
SAFECOPY(emsg.pid, p);
if((p = smsg.ftn_tid) != NULL)
if((p = smsg->ftn_tid) != NULL)
SAFECOPY(emsg.tid, p);
else
SAFECOPY(emsg.tid, sbbsecho_pid());
......@@ -438,25 +438,25 @@ const char* iniTimeStr(time_t t)
return tstr;
}
void fwrite_echostat_msg(FILE* fp, echostat_msg_t msg, const char* prefix)
void fwrite_echostat_msg(FILE* fp, const echostat_msg_t* msg, const char* prefix)
{
echostat_msg_t zero = {{0}};
if(memcmp(&msg, &zero, sizeof(msg)) == 0)
if(memcmp(msg, &zero, sizeof(msg)) == 0)
return;
if(msg.to[0]) fprintf(fp, "%s.to = %s\n" , prefix, msg.to);
if(msg.from[0]) fprintf(fp, "%s.from = %s\n" , prefix, msg.from);
if(msg.subj[0]) fprintf(fp, "%s.subj = %s\n" , prefix, msg.subj);
if(msg.msg_id[0]) fprintf(fp, "%s.msg_id = %s\n" , prefix, msg.msg_id);
if(msg.reply_id[0]) fprintf(fp, "%s.reply_id = %s\n" , prefix, msg.reply_id);
if(msg.pid[0]) fprintf(fp, "%s.pid = %s\n" , prefix, msg.pid);
if(msg.tid[0]) fprintf(fp, "%s.tid = %s\n" , prefix, msg.tid);
fprintf(fp, "%s.length = %lu\n" , prefix, (ulong)msg.length);
fprintf(fp, "%s.msg_time = %s\n" , prefix, iniTimeStr(msg.msg_time));
if(msg.msg_tz[0]) fprintf(fp, "%s.msg_tz = %s\n" , prefix, msg.msg_tz);
fprintf(fp, "%s.localtime = %s\n" , prefix, iniTimeStr(msg.localtime));
if(msg.origaddr.zone)
fprintf(fp, "%s.origaddr = %s\n" , prefix, faddrtoa(&msg.origaddr));
fprintf(fp, "%s.pkt_orig = %s\n" , prefix, faddrtoa(&msg.pkt_orig));
if(msg->to[0]) fprintf(fp, "%s.to = %s\n" , prefix, msg->to);
if(msg->from[0]) fprintf(fp, "%s.from = %s\n" , prefix, msg->from);
if(msg->subj[0]) fprintf(fp, "%s.subj = %s\n" , prefix, msg->subj);
if(msg->msg_id[0]) fprintf(fp, "%s.msg_id = %s\n" , prefix, msg->msg_id);
if(msg->reply_id[0]) fprintf(fp, "%s.reply_id = %s\n", prefix, msg->reply_id);
if(msg->pid[0]) fprintf(fp, "%s.pid = %s\n" , prefix, msg->pid);
if(msg->tid[0]) fprintf(fp, "%s.tid = %s\n" , prefix, msg->tid);
fprintf(fp, "%s.length = %lu\n" , prefix, (ulong)msg->length);
fprintf(fp, "%s.msg_time = %s\n" , prefix, iniTimeStr(msg->msg_time));
if(msg->msg_tz[0]) fprintf(fp, "%s.msg_tz = %s\n" , prefix, msg->msg_tz);
fprintf(fp, "%s.localtime = %s\n" , prefix, iniTimeStr(msg->localtime));
if(msg->origaddr.zone)
fprintf(fp, "%s.origaddr = %s\n" , prefix, faddrtoa(&msg->origaddr));
fprintf(fp, "%s.pkt_orig = %s\n" , prefix, faddrtoa(&msg->pkt_orig));
}
void fwrite_echostat(FILE* fp, echostat_t* stat)
......@@ -468,8 +468,8 @@ void fwrite_echostat(FILE* fp, echostat_t* stat)
fprintf(fp, "Title = %s\n" , desc);
for(int type = 0; type < ECHOSTAT_MSG_TYPES; type++) {
char prefix[32];
sprintf(prefix, "First%s", echostat_msg_type[type]) , fwrite_echostat_msg(fp, stat->first[type], prefix);
sprintf(prefix, "Last%s", echostat_msg_type[type]) , fwrite_echostat_msg(fp, stat->last[type], prefix);
sprintf(prefix, "First%s", echostat_msg_type[type]) , fwrite_echostat_msg(fp, &stat->first[type], prefix);
sprintf(prefix, "Last%s", echostat_msg_type[type]) , fwrite_echostat_msg(fp, &stat->last[type], prefix);
if(stat->total[type] != 0)
fprintf(fp, "Total%s = %lu\n" , echostat_msg_type[type], stat->total[type]);
}
......@@ -1302,6 +1302,8 @@ int file_to_netmail(FILE* infile, const char* title, fidoaddr_t dest, const char
l=len=ftell(infile);
if(len>8192L)
len=8192L;
else if(len < 1)
return 0;
rewind(infile);
if((buf=(char *)malloc(len+1))==NULL) {
lprintf(LOG_ERR,"ERROR line %d allocating %lu for file to netmail buf",__LINE__,len);
......@@ -2818,7 +2820,7 @@ bool unpack_bundle(const char* inbound)
/****************************************************************************/
int mv(const char *insrc, const char *indest, bool copy)
{
char buf[4096],str[256];
char buf[4096];
char src[MAX_PATH+1];
char dest[MAX_PATH+1];
int ind,outd;
......@@ -2836,7 +2838,7 @@ int mv(const char *insrc, const char *indest, bool copy)
}
if(isdir(dest)) {
backslash(dest);
strcat(dest, getfname(src));
SAFECAT(dest, getfname(src));
}
if(!copy && fexistcase(dest)) {
lprintf(LOG_WARNING,"MV ERROR: Destination file already exists '%s'",dest);
......@@ -2858,7 +2860,7 @@ int mv(const char *insrc, const char *indest, bool copy)
}
if((inp=fdopen(ind,"rb"))==NULL) {
close(ind);
lprintf(LOG_ERR,"MV ERROR %u (%s) fdopening '%s'",errno,strerror(errno),str);
lprintf(LOG_ERR,"MV ERROR %u (%s) fdopening '%s'",errno,strerror(errno),src);
return(-1);
}
setvbuf(inp,NULL,_IOFBF,8*1024);
......@@ -2870,7 +2872,7 @@ int mv(const char *insrc, const char *indest, bool copy)
if((outp=fdopen(outd,"wb"))==NULL) {
close(outd);
fclose(inp);
lprintf(LOG_ERR,"MV ERROR %u (%s) fdopening '%s'",errno,strerror(errno),str);
lprintf(LOG_ERR,"MV ERROR %u (%s) fdopening '%s'",errno,strerror(errno),dest);
return(-1);
}
setvbuf(outp,NULL,_IOFBF,8*1024);
......@@ -3217,11 +3219,11 @@ char* getfmsg(FILE* stream, ulong* outlen)
{
uchar* fbuf;
int ch;
long start;
off_t start;
ulong l,length;
length=0L;
start=ftell(stream); /* Beginning of Message */
start=ftello(stream); /* Beginning of Message */
while(1) {
ch=fgetc(stream); /* Look for Terminating NULL */
if(ch==0 || ch==EOF) /* Found end of message */
......@@ -3235,7 +3237,7 @@ char* getfmsg(FILE* stream, ulong* outlen)
return(NULL);
}
(void)fseek(stream,start,SEEK_SET);
(void)fseeko(stream,start,SEEK_SET);
for(l=0;l<length;l++)
fbuf[l]=(uchar)fgetc(stream);
if(ch==0)
......@@ -3781,10 +3783,10 @@ void putfmsg(FILE* stream, const char* fbuf, fmsghdr_t* hdr, area_t area
net_exists=1;
addr.net=seenbys.addr[u].net;
sprintf(str,"%d/",addr.net);
strcat(seenby,str);
SAFECAT(seenby,str);
}
sprintf(str,"%d",seenbys.addr[u].node);
strcat(seenby,str);
SAFECAT(seenby,str);
if(lastlen+strlen(seenby)<80) {
(void)fwrite(seenby,strlen(seenby),1,stream);
lastlen+=strlen(seenby);
......@@ -3812,10 +3814,10 @@ void putfmsg(FILE* stream, const char* fbuf, fmsghdr_t* hdr, area_t area
net_exists=1;
addr.net=area.link[u].net;
sprintf(str,"%d/",addr.net);
strcat(seenby,str);
SAFECAT(seenby,str);
}
sprintf(str,"%d",area.link[u].node);
strcat(seenby,str);
SAFECAT(seenby,str);
if(lastlen+strlen(seenby)<80) {
(void)fwrite(seenby,strlen(seenby),1,stream);
lastlen+=strlen(seenby);
......@@ -3841,10 +3843,10 @@ void putfmsg(FILE* stream, const char* fbuf, fmsghdr_t* hdr, area_t area
net_exists=1;
addr.net=scfg.faddr[u].net;
sprintf(str,"%d/",addr.net);
strcat(seenby,str);
SAFECAT(seenby,str);
}
sprintf(str,"%d",scfg.faddr[u].node);
strcat(seenby,str);
SAFECAT(seenby,str);
if(lastlen+strlen(seenby)<80) {
(void)fwrite(seenby,strlen(seenby),1,stream);
lastlen+=strlen(seenby);
......@@ -3873,10 +3875,10 @@ void putfmsg(FILE* stream, const char* fbuf, fmsghdr_t* hdr, area_t area
net_exists=1;
addr.net=paths.addr[u].net;
sprintf(str,"%d/",addr.net);
strcat(seenby,str);
SAFECAT(seenby,str);
}
sprintf(str,"%d",paths.addr[u].node);
strcat(seenby,str);
SAFECAT(seenby,str);
if(lastlen+strlen(seenby)<80) {
(void)fwrite(seenby,strlen(seenby),1,stream);
lastlen+=strlen(seenby);
......@@ -3897,10 +3899,10 @@ void putfmsg(FILE* stream, const char* fbuf, fmsghdr_t* hdr, area_t area
net_exists=1;
addr.net=sysaddr.net;
sprintf(str,"%d/",addr.net);
strcat(seenby,str);
SAFECAT(seenby,str);
}
sprintf(str,"%d",sysaddr.node);
strcat(seenby,str);
SAFECAT(seenby,str);
if(lastlen+strlen(seenby)<80)
(void)fwrite(seenby,strlen(seenby),1,stream);
else {
......@@ -5049,7 +5051,7 @@ void export_echomail(const char* sub_code, const nodecfg_t* nodecfg, bool rescan
exported++;
exp++;
new_echostat_msg(stat, ECHOSTAT_MSG_EXPORTED
,smsg_to_echostat_msg(msg, strlen(fmsgbuf), scfg.sub[subnum]->faddr));
,smsg_to_echostat_msg(&msg, strlen(fmsgbuf), scfg.sub[subnum]->faddr));
FREE_AND_NULL(fmsgbuf);
printf("Exp: %lu ",exp);
smb_unlockmsghdr(&smb, &msg);
......@@ -5677,7 +5679,8 @@ void find_stray_packets(void)
}
terminator = ~FIDO_PACKET_TERMINATOR;
(void)fseek(fp, flen-sizeof(terminator), SEEK_SET);
(void)fread(&terminator, sizeof(terminator), 1, fp);
if(fread(&terminator, sizeof(terminator), 1, fp) != 1)
lprintf(LOG_WARNING, "Failure reading last byte from %s", packet);
fclose(fp);
if(!parse_pkthdr(&pkthdr, &pkt_orig, &pkt_dest, &pkt_type)) {
lprintf(LOG_WARNING,"Failure to parse packet (%s) header, type: %u"
......@@ -5878,9 +5881,9 @@ void import_packets(const char* inbound, nodecfg_t* inbox, bool secure)
hdr.attr&=~FIDO_LOCAL; /* Strip local bit, obviously not created locally */
if(strncmp(fmsgbuf, "AREA:", 5) != 0) { /* Netmail */
(void)fseek(fidomsg, msg_offset, SEEK_SET);
(void)fseeko(fidomsg, msg_offset, SEEK_SET);
import_netmail("", hdr, fidomsg, inbound);
(void)fseek(fidomsg, next_msg, SEEK_SET);
(void)fseeko(fidomsg, next_msg, SEEK_SET);
printf("\n");
continue;
}
......
/* Synchronet file database scanning routines */
/* $Id: scandirs.cpp,v 1.8 2018/10/22 04:18:06 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -40,7 +26,7 @@
/****************************************************************************/
void sbbs_t::scandirs(long mode)
{
char ch,str[256];
char ch,str[256]="";
char tmp[512];
int s;
uint i,k;
......@@ -55,7 +41,6 @@ void sbbs_t::scandirs(long mode)
if(ch!='A') {
if(mode&FL_ULTIME) { /* New file scan */
bprintf(text[NScanHdr],timestr(ns_time));
str[0]=0;
}
else if(mode==FL_NO_HDR) { /* Search for a string */
if(!getfilespec(tmp))
......@@ -115,7 +100,7 @@ void sbbs_t::scandirs(long mode)
/****************************************************************************/
void sbbs_t::scanalldirs(long mode)
{
char str[256];
char str[256]="";
char tmp[512];
int s;
uint i,j,k,d;
......@@ -124,7 +109,6 @@ void sbbs_t::scanalldirs(long mode)
k=0;
if(mode&FL_ULTIME) { /* New file scan */
bprintf(text[NScanHdr],timestr(ns_time));
str[0]=0;
}
else if(mode==FL_NO_HDR) { /* Search for a string */
if(!getfilespec(tmp))
......
......@@ -1309,9 +1309,9 @@ void getar(char *desc, char *inar)
for(i=0;i<n;i++) {
for(j=0;j<7;j++)
if(!strnicmp(ar+i,wday[j],3)) {
strcat(str,ultoa(j,tmp,10));
SAFECAT(str,ultoa(j,tmp,10));
i+=2;
break;
break;
}
if(j==7)
strncat(str,ar+i,1);
......@@ -1440,7 +1440,6 @@ void getar(char *desc, char *inar)
if(ar[i]!=' ' && ar[i]!='&')
strncat(str,ar+i,1);
SAFECOPY(ar,str);
len=strlen(ar);
}
i=0;
sprintf(opt[i++],"Requirement String (%s)",ar);
......@@ -2180,7 +2179,7 @@ void bail(int code)
{
if(code) {
printf("\nHit enter to continue...");
getchar();