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 989d7bbc authored by rswindell's avatar rswindell

Using new SAFECOPY macro for auto-bounds-checked strcpy.

parent 08a74503
......@@ -133,7 +133,7 @@ bool sbbs_t::answer()
strcat(str,COPYRIGHT_NOTICE);
strip_ctrl(str);
center(str);
while(i++<50 && l<sizeof(str)-1) { /* wait up to 5 seconds for response */
while(i++<50 && l<(int)sizeof(str)-1) { /* wait up to 5 seconds for response */
c=(incom()&0x7f);
if(!c) {
mswait(100);
......@@ -149,7 +149,7 @@ bool sbbs_t::answer()
}
}
while((c=(incom()&0x7f))!=0 && l<sizeof(str)-1) {
while((c=(incom()&0x7f))!=0 && l<(int)sizeof(str)-1) {
str[l++]=c;
mswait(1);
}
......@@ -202,7 +202,7 @@ bool sbbs_t::answer()
useron.misc&=~(ANSI|COLOR|RIP|WIP);
useron.misc|=autoterm;
sprintf(useron.comp, "%.*s", sizeof(useron.comp)-1, client_name);
SAFECOPY(useron.comp,client_name);
if(!useron.number && sys_status&SS_RLOGIN) {
CRLF;
......@@ -238,13 +238,13 @@ bool sbbs_t::answer()
/* Save the IP to the user's note */
if(cid[0]) {
sprintf(useron.note, "%.*s", sizeof(useron.note)-1, cid);
SAFECOPY(useron.note,cid);
putuserrec(&cfg,useron.number,U_NOTE,LEN_NOTE,useron.note);
}
/* Save host name to the user's computer description */
if(client_name[0]) {
sprintf(useron.comp, "%.*s", sizeof(useron.comp)-1, client_name);
SAFECOPY(useron.comp,client_name);
putuserrec(&cfg,useron.number,U_COMP,LEN_COMP,useron.comp);
}
......
......@@ -140,10 +140,10 @@ char* sbbs_t::atcode(char* sp, char* str)
up=0;
char days[64]="";
if((up/(24*60*60))>=2) {
sprintf(days,"%u days ",up/(24*60*60));
sprintf(days,"%lu days ",up/(24*60*60));
up%=(24*60*60);
}
sprintf(str,"%s%u:%02u"
sprintf(str,"%s%lu:%02lu"
,days
,up/(60*60)
,(up/60)%60
......@@ -383,7 +383,7 @@ char* sbbs_t::atcode(char* sp, char* str)
if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
now=time(NULL);
sprintf(str,"%u",(now-logontime)/60);
sprintf(str,"%lu",(now-logontime)/60);
return(str);
}
......@@ -410,7 +410,7 @@ char* sbbs_t::atcode(char* sp, char* str)
if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
gettimeleft();
sprintf(str,"%u",timeleft/60);
sprintf(str,"%lu",timeleft/60);
return(str);
}
......@@ -439,7 +439,7 @@ char* sbbs_t::atcode(char* sp, char* str)
}
if(!strcmp(sp,"MSGREAD")) {
sprintf(str,"%u",posts_read);
sprintf(str,"%lu",posts_read);
return(str);
}
......@@ -536,7 +536,7 @@ char* sbbs_t::atcode(char* sp, char* str)
l=useron.expire-now;
if(l<0)
l=0;
sprintf(str,"%u",l/(1440L*60L));
sprintf(str,"%lu",l/(1440L*60L));
return(str);
}
......@@ -801,29 +801,29 @@ char* sbbs_t::atcode(char* sp, char* str)
getstats(&cfg,0,&stats);
sp+=6;
if(!strcmp(sp,"LOGONS"))
sprintf(str,"%u",stats.logons);
sprintf(str,"%lu",stats.logons);
else if(!strcmp(sp,"LTODAY"))
sprintf(str,"%u",stats.ltoday);
sprintf(str,"%lu",stats.ltoday);
else if(!strcmp(sp,"TIMEON"))
sprintf(str,"%u",stats.timeon);
sprintf(str,"%lu",stats.timeon);
else if(!strcmp(sp,"TTODAY"))
sprintf(str,"%u",stats.ttoday);
sprintf(str,"%lu",stats.ttoday);
else if(!strcmp(sp,"ULS"))
sprintf(str,"%u",stats.uls);
sprintf(str,"%lu",stats.uls);
else if(!strcmp(sp,"ULB"))
sprintf(str,"%u",stats.ulb);
sprintf(str,"%lu",stats.ulb);
else if(!strcmp(sp,"DLS"))
sprintf(str,"%u",stats.dls);
sprintf(str,"%lu",stats.dls);
else if(!strcmp(sp,"DLB"))
sprintf(str,"%u",stats.dlb);
sprintf(str,"%lu",stats.dlb);
else if(!strcmp(sp,"PTODAY"))
sprintf(str,"%u",stats.ptoday);
sprintf(str,"%lu",stats.ptoday);
else if(!strcmp(sp,"ETODAY"))
sprintf(str,"%u",stats.etoday);
sprintf(str,"%lu",stats.etoday);
else if(!strcmp(sp,"FTODAY"))
sprintf(str,"%u",stats.ftoday);
sprintf(str,"%lu",stats.ftoday);
else if(!strcmp(sp,"NUSERS"))
sprintf(str,"%u",stats.nusers);
sprintf(str,"%lu",stats.nusers);
return(str);
}
......
......@@ -3448,7 +3448,7 @@ int main(int argc, char **argv)
bail(1);
}
sprintf(bin_file,"%.*s",sizeof(bin_file)-1,str);
SAFECOPY(bin_file,str);
printf("\nCompiling %s...\n",src);
......
......@@ -242,7 +242,7 @@ void sbbs_t::center(char *instr)
char str[256];
int i,j;
sprintf(str,"%.*s",sizeof(str)-1,instr);
SAFECOPY(str,instr);
truncsp(str);
j=bstrlen(str);
for(i=0;i<(80-j)/2;i++)
......
......@@ -56,7 +56,7 @@ bool sbbs_t::email(int usernumber, char *top, char *subj, long mode)
node_t node;
smbmsg_t msg;
sprintf(title,"%.*s",LEN_TITLE,subj);
SAFECOPY(title,subj);
if(useron.etoday>=cfg.level_emailperday[useron.level] && !SYSOP) {
bputs(text[TooManyEmailsToday]);
......
......@@ -578,7 +578,7 @@ long sbbs_t::js_execfile(char *cmd)
return(-1);
}
sprintf(cmdline,"%.*s",sizeof(cmdline)-1,cmd);
SAFECOPY(cmdline,cmd);
p=strchr(cmdline,' ');
if(p!=NULL) {
*p=0;
......@@ -590,7 +590,7 @@ long sbbs_t::js_execfile(char *cmd)
if(!strchr(fname,BACKSLASH))
sprintf(path,"%s%s",cfg.exec_dir,fname);
else
sprintf(path,"%.*s",sizeof(path)-4,fname);
sprintf(path,"%.*s",(int)sizeof(path)-4,fname);
if(!strchr(path,'.'))
strcat(path,".js");
......
......@@ -414,12 +414,12 @@ BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
{
char c,str[256],ixbname[12],HUGE16 *ixbbuf,fname[13];
int file;
int i,file;
long l,length;
strcpy(fname,f->name);
for(c=8;c<12;c++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[c]=fname[c+1];
for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[i]=fname[i+1];
sprintf(str,"%s%s.ixb",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
// errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
......@@ -447,9 +447,9 @@ BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
return(FALSE);
}
for(l=0;l<length;l+=F_IXBSIZE) {
for(c=0;c<11;c++)
ixbname[c]=ixbbuf[l+c];
ixbname[c]=0;
for(i=0;i<11;i++)
ixbname[i]=ixbbuf[l+i];
ixbname[i]=0;
if(stricmp(ixbname,fname))
if(lwrite(file,&ixbbuf[l],F_IXBSIZE)!=F_IXBSIZE) {
close(file);
......@@ -486,13 +486,13 @@ BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
{
char str[256],c,fname[13],HUGE16 *ixbbuf;
int file;
int i,file;
long length,l;
sprintf(fname,"%.12s",filename);
strupr(fname);
for(c=8;c<12;c++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[c]=fname[c+1];
for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[i]=fname[i+1];
sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir,cfg->dir[dirnum]->code);
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) return(FALSE);
length=filelength(file);
......@@ -510,9 +510,9 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
return(FALSE); }
close(file);
for(l=0;l<length;l+=F_IXBSIZE) {
for(c=0;c<11;c++)
if(fname[c]!=toupper(ixbbuf[l+c])) break;
if(c==11) break; }
for(i=0;i<11;i++)
if(fname[i]!=toupper(ixbbuf[l+i])) break;
if(i==11) break; }
FREE((char *)ixbbuf);
if(l!=length)
return(TRUE);
......@@ -524,7 +524,7 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
/****************************************************************************/
char* DLLCALL padfname(char *filename, char *str)
{
char c,d;
int c,d;
for(c=0;c<8;c++)
if(filename[c]=='.' || !filename[c]) break;
......@@ -551,7 +551,7 @@ char* DLLCALL padfname(char *filename, char *str)
/****************************************************************************/
char* DLLCALL unpadfname(char *filename, char *str)
{
char c,d;
int c,d;
for(c=0,d=0;filename[c];c++)
if(filename[c]!=SP) str[d++]=filename[c];
......
......@@ -426,7 +426,7 @@ long sbbs_t::getkeys(char *keys, ulong max)
uchar ch,n=0,c;
ulong i=0;
sprintf(str,"%.*s",sizeof(str)-1,keys);
SAFECOPY(str,keys);
strupr(str);
while(online) {
ch=getkey(K_UPPER);
......
......@@ -529,10 +529,10 @@ static JSBool js_bbs_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
sbbs->posts_read=val;
break;
case BBS_PROP_MENU_DIR:
sprintf(sbbs->menu_dir,"%.*s",sizeof(sbbs->menu_dir)-1,p);
SAFECOPY(sbbs->menu_dir,p);
break;
case BBS_PROP_MENU_FILE:
sprintf(sbbs->menu_file,"%.*s",sizeof(sbbs->menu_file)-1,p);
SAFECOPY(sbbs->menu_file,p);
break;
case BBS_PROP_MAIN_CMDS:
sbbs->main_cmds=val;
......@@ -597,10 +597,10 @@ static JSBool js_bbs_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
break;
case BBS_PROP_RLOGIN_NAME:
sprintf(sbbs->rlogin_name,"%.*s",sizeof(sbbs->rlogin_name)-1,p);
SAFECOPY(sbbs->rlogin_name,p);
break;
case BBS_PROP_CLIENT_NAME:
sprintf(sbbs->client_name,"%.*s",sizeof(sbbs->client_name)-1,p);
SAFECOPY(sbbs->client_name,p);
break;
case BBS_PROP_ALTUL:
......
......@@ -366,7 +366,7 @@ js_gettemplate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
if(js_str==NULL)
str[0]=0;
else
sprintf(str, "%.*s", sizeof(str)-1, JS_GetStringBytes(js_str));
SAFECOPY(str,JS_GetStringBytes(js_str));
sbbs->gettmplt(str,JS_GetStringBytes(js_fmt),mode);
js_str = JS_NewStringCopyZ(cx, str);
......
......@@ -86,7 +86,7 @@ js_file_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
return(JS_FALSE);
}
sprintf(p->name,"%.*s",sizeof(p->name)-1,JS_GetStringBytes(str));
SAFECOPY(p->name,JS_GetStringBytes(str));
if(!JS_SetPrivate(cx, obj, p)) {
dbprintf(TRUE, p, "JS_SetPrivate failed");
......@@ -147,7 +147,7 @@ js_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} else
JS_ValueToInt32(cx,argv[i],&bufsize);
}
sprintf(p->mode,"%.*s",sizeof(p->mode)-1,mode);
SAFECOPY(p->mode,mode);
if((p->fp=fopen(p->name,p->mode))==NULL)
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
......
......@@ -179,7 +179,7 @@ JSObject* DLLCALL js_CreateMsgAreaObject(JSContext* cx, JSObject* parent, scfg_t
return(NULL);
if(cfg->sub[d]->newsgroup[0])
sprintf(str,"%.*s",sizeof(str)-1,cfg->sub[d]->newsgroup);
SAFECOPY(str,cfg->sub[d]->newsgroup);
else {
sprintf(str,"%s.%s",cfg->grp[l]->sname,cfg->sub[d]->sname);
for(c=0;str[c];c++)
......
......@@ -71,7 +71,7 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
for(i=0;i<cfg->sys_nodes;i++)
prep_dir(cfg->ctrl_dir, cfg->node_path[i]);
sprintf(cfg->node_dir,"%.*s",sizeof(cfg->node_dir)-1,cfg->node_path[cfg->node_num-1]);
SAFECOPY(cfg->node_dir,cfg->node_path[cfg->node_num-1]);
prep_dir(cfg->ctrl_dir, cfg->node_dir);
if(read_node_cfg(cfg, error)==FALSE)
return(FALSE);
......@@ -253,7 +253,7 @@ BOOL md(char *inpath)
DIR* dir;
char path[MAX_PATH+1];
sprintf(path,"%.*s",MAX_PATH,inpath);
SAFECOPY(path,inpath);
if(path[0]==0)
return(FALSE);
......
......@@ -48,7 +48,7 @@ int sbbs_t::login(char *username, char *pw)
if(cfg.node_dollars_per_call && noyes(text[AreYouSureQ]))
return(LOGIC_FALSE);
sprintf(str,"%.*s",sizeof(str)-1,username);
SAFECOPY(str,username);
if(str[0]=='*') {
memmove(str,str+1,strlen(str));
......
......@@ -400,7 +400,7 @@ js_prompt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(argc>1) {
if((str=JS_ValueToString(cx, argv[1]))==NULL)
return(JS_FALSE);
sprintf(instr,"%.*s",sizeof(instr)-1,JS_GetStringBytes(str));
SAFECOPY(instr,JS_GetStringBytes(str));
} else
instr[0]=0;
......@@ -1599,7 +1599,7 @@ sbbs_t::sbbs_t(ushort node_num, DWORD addr, char* name, SOCKET sd,
memcpy(&client,client_info,sizeof(client));
client_addr = addr;
client_socket = sd;
sprintf(client_name, "%.*s", (int)sizeof(client_name)-1, name);
SAFECOPY(client_name, name);
client_socket_dup=INVALID_SOCKET;
client_ident[0]=0;
......@@ -3139,8 +3139,7 @@ void DLLCALL bbs_thread(void* arg)
lprintf("!ERROR %d changing directory to: %s", errno, startup->ctrl_dir);
/* Initial configuration and load from CNF files */
sprintf(scfg.ctrl_dir, "%.*s", (int)sizeof(scfg.ctrl_dir)-1
,startup->ctrl_dir);
SAFECOPY(scfg.ctrl_dir,startup->ctrl_dir);
lprintf("Loading configuration files from %s", scfg.ctrl_dir);
scfg.size=sizeof(scfg);
scfg.node_num=startup->first_node;
......@@ -3153,7 +3152,7 @@ void DLLCALL bbs_thread(void* arg)
scfg_reloaded=true;
if(startup->host_name[0]==0)
sprintf(startup->host_name,"%.*s",sizeof(startup->host_name),scfg.sys_inetaddr);
SAFECOPY(startup->host_name,scfg.sys_inetaddr);
if(!(scfg.sys_misc&SM_LOCAL_TZ) && !(startup->options&BBS_OPT_LOCAL_TIMEZONE)) {
if(putenv("TZ=UTC0"))
......@@ -3613,8 +3612,8 @@ void DLLCALL bbs_thread(void* arg)
/* Initialize client display */
client.size=sizeof(client);
client.time=time(NULL);
sprintf(client.addr,"%.*s",(int)sizeof(client.addr)-1,host_ip);
sprintf(client.host,"%.*s",(int)sizeof(client.host)-1,host_name);
SAFECOPY(client.addr,host_ip);
SAFECOPY(client.host,host_name);
client.port=ntohs(client_addr.sin_port);
client.protocol=rlogin ? "RLogin":"Telnet";
client.user="<unknown>";
......@@ -3654,8 +3653,7 @@ void DLLCALL bbs_thread(void* arg)
/* copy the IDENT response, if any */
if(identity!=NULL)
sprintf(new_node->client_ident,"%.*s"
,sizeof(new_node->client_ident)-1,identity);
SAFECOPY(new_node->client_ident,identity);
if(new_node->init()==false) {
lprintf("%04d !Node %d Initialization failure"
......
......@@ -347,7 +347,7 @@ static int bbs_lputs(char *str)
,tm_p->tm_mon+1,tm_p->tm_mday
,tm_p->tm_hour,tm_p->tm_min,tm_p->tm_sec);
sprintf(logline,"%s %.*s",tstr,sizeof(logline)-2,str);
sprintf(logline,"%s %.*s",tstr,(int)sizeof(logline)-32,str);
truncsp(logline);
lputs(logline);
......@@ -397,7 +397,7 @@ static int ftp_lputs(char *str)
,tm_p->tm_mon+1,tm_p->tm_mday
,tm_p->tm_hour,tm_p->tm_min,tm_p->tm_sec);
sprintf(logline,"%sftp %.*s",tstr,sizeof(logline)-2,str);
sprintf(logline,"%sftp %.*s",tstr,(int)sizeof(logline)-32,str);
truncsp(logline);
lputs(logline);
......@@ -447,7 +447,7 @@ static int mail_lputs(char *str)
,tm_p->tm_mon+1,tm_p->tm_mday
,tm_p->tm_hour,tm_p->tm_min,tm_p->tm_sec);
sprintf(logline,"%smail %.*s",tstr,sizeof(logline)-2,str);
sprintf(logline,"%smail %.*s",tstr,(int)sizeof(logline)-32,str);
truncsp(logline);
lputs(logline);
......@@ -497,7 +497,7 @@ static int services_lputs(char *str)
,tm_p->tm_mon+1,tm_p->tm_mday
,tm_p->tm_hour,tm_p->tm_min,tm_p->tm_sec);
sprintf(logline,"%ssrvc %.*s",tstr,sizeof(logline)-2,str);
sprintf(logline,"%ssrvc %.*s",tstr,(int)sizeof(logline)-32,str);
truncsp(logline);
lputs(logline);
......@@ -547,7 +547,7 @@ static int event_lputs(char *str)
,tm_p->tm_mon+1,tm_p->tm_mday
,tm_p->tm_hour,tm_p->tm_min,tm_p->tm_sec);
sprintf(logline,"%sevnt %.*s",tstr,sizeof(logline)-2,str);
sprintf(logline,"%sevnt %.*s",tstr,(int)sizeof(logline)-32,str);
truncsp(logline);
lputs(logline);
......@@ -964,7 +964,7 @@ int main(int argc, char** argv)
{
new_uid_name=arg;
old_uid = getuid();
if(pw_entry=getpwnam(new_uid_name))
if((pw_entry=getpwnam(new_uid_name))!=0)
{
new_uid=pw_entry->pw_uid;
new_gid=pw_entry->pw_gid;
......
......@@ -3358,10 +3358,10 @@ int import_netmail(char *path,fmsghdr_t hdr, FILE *fidomsg)
addr.net=hdr.orignet;
addr.node=hdr.orignode;
addr.point=hdr.origpoint;
sprintf(hdr.to ,"%.*s",sizeof(hdr.to)-1 ,scfg.sys_op);
sprintf(hdr.from,"%.*s",sizeof(hdr.from)-1 ,"SBBSecho");
sprintf(str ,"%.*s",sizeof(str)-1 ,hdr.subj);
sprintf(hdr.subj,"%.*s",sizeof(hdr.subj)-1 ,"Areafix Request");
SAFECOPY(hdr.to,scfg.sys_op);
SAFECOPY(hdr.from,"SBBSecho");
SAFECOPY(str,hdr.subj);
SAFECOPY(hdr.subj,"Areafix Request");
hdr.origzone=hdr.orignet=hdr.orignode=hdr.origpoint=0;
p=process_areafix(addr,fmsgbuf,str);
if(p && cfg.notify)
......@@ -3950,7 +3950,7 @@ int main(int argc, char **argv)
if(p==NULL) {
printf("\7\nSBBSCTRL environment variable not set.\n");
bail(1); }
sprintf(scfg.ctrl_dir,"%.*s",sizeof(scfg.ctrl_dir)-1,p);
SAFECOPY(scfg.ctrl_dir,p);
if(_chdir(scfg.ctrl_dir)!=0)
printf("!ERROR changing directory to: %s", scfg.ctrl_dir);
......
......@@ -245,24 +245,6 @@ static void truncsp(char *str)
str[c]=0;
}
static u_long resolve_ip(char *addr)
{
HOSTENT* host;
char* p;
for(p=addr;*p;p++)
if(*p!='.' && !isdigit(*p))
break;
if(!(*p))
return(inet_addr(addr));
if ((host=gethostbyname(addr))==NULL) {
lprintf("0000 !ERROR resolving hostname: %s",addr);
return(0);
}
return(*((ulong*)host->h_addr_list[0]));
}
/* Global JavaScript Methods */
static JSBool
js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
......@@ -349,9 +331,9 @@ js_login(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if(argc>2)
inc_logons=JSVAL_TO_BOOLEAN(argv[2]);
sprintf(user.note,"%.*s",sizeof(user.note)-1,client->client->addr);
sprintf(user.comp,"%.*s",sizeof(user.comp)-1,client->client->host);
sprintf(user.modem,"%.*s",sizeof(user.modem)-1,client->service->protocol);
SAFECOPY(user.note,client->client->addr);
SAFECOPY(user.comp,client->client->host);
SAFECOPY(user.modem,client->service->protocol);
if(inc_logons) {
user.logons++;
......@@ -663,8 +645,8 @@ static void js_service_thread(void* arg)
client.size=sizeof(client);
client.time=time(NULL);
sprintf(client.addr,"%.*s",(int)sizeof(client.addr)-1,inet_ntoa(service_client.addr.sin_addr));
sprintf(client.host,"%.*s",(int)sizeof(client.host)-1,host_name);
SAFECOPY(client.addr,inet_ntoa(service_client.addr.sin_addr));
SAFECOPY(client.host,host_name);
client.port=ntohs(service_client.addr.sin_port);
client.protocol=service->protocol;
client.user="<unknown>";
......@@ -829,8 +811,8 @@ static void native_service_thread(void* arg)
client.size=sizeof(client);
client.time=time(NULL);
sprintf(client.addr,"%.*s",(int)sizeof(client.addr)-1,inet_ntoa(service_client.addr.sin_addr));
sprintf(client.host,"%.*s",(int)sizeof(client.host)-1,host_name);
SAFECOPY(client.addr,inet_ntoa(service_client.addr.sin_addr));
SAFECOPY(client.host,host_name);
client.port=ntohs(service_client.addr.sin_port);
client.protocol=service->protocol;
client.user="<unknown>";
......@@ -927,7 +909,7 @@ static service_t* read_services_cfg(char* services_cfg, DWORD* services)
tp=p;
while(*tp && *tp>' ') tp++;
*tp=0;
sprintf(service[*services].protocol,"%.*s",sizeof(service[0].protocol),p);
sprintf(service[*services].protocol,"%.*s",(int)sizeof(service[0].protocol)-1,p);
p=tp+1;
while(*p && *p<=' ') p++;
service[*services].port=atoi(p);
......@@ -937,7 +919,7 @@ static service_t* read_services_cfg(char* services_cfg, DWORD* services)
service[*services].options=strtol(p,NULL,16);
NEXT_FIELD(p);
sprintf(service[*services].cmd,"%.*s",sizeof(service[0].cmd),p);
sprintf(service[*services].cmd,"%.*s",(int)sizeof(service[0].cmd)-1,p);
truncsp(service[*services].cmd);
(*services)++;
......@@ -1066,8 +1048,7 @@ void DLLCALL services_thread(void* arg)
,ctime(&t),startup->options);
/* Initial configuration and load from CNF files */
sprintf(scfg.ctrl_dir, "%.*s", (int)sizeof(scfg.ctrl_dir)-1
,startup->ctrl_dir);
SAFECOPY(scfg.ctrl_dir, startup->ctrl_dir);
lprintf("Loading configuration files from %s", scfg.ctrl_dir);
scfg.size=sizeof(scfg);
if(!load_cfg(&scfg, NULL, TRUE, error)) {
......@@ -1078,7 +1059,7 @@ void DLLCALL services_thread(void* arg)
}
if(startup->host_name[0]==0)
sprintf(startup->host_name,"%.*s",sizeof(startup->host_name),scfg.sys_inetaddr);
SAFECOPY(startup->host_name,scfg.sys_inetaddr);
if(!(scfg.sys_misc&SM_LOCAL_TZ) && !(startup->options&BBS_OPT_LOCAL_TIMEZONE)) {
if(putenv("TZ=UTC0"))
......@@ -1279,7 +1260,7 @@ void DLLCALL services_thread(void* arg)
client->service=&service[i];
<