Commits (11)
......@@ -729,13 +729,13 @@ int main(int argc, char **argv)
SAFECOPY(fdesc, "no description given");
}
sprintf(str,"%s%s", scfg.dir[dirnum]->path, fname);
SAFEPRINTF2(str,"%s%s", scfg.dir[dirnum]->path, fname);
if(mode&FILE_DATE)
sprintf(fdesc, "%s ", unixtodstr(&scfg,(time32_t)fdate(str),tmp));
if(mode&TODAYS_DATE)
sprintf(fdesc, "%s ", unixtodstr(&scfg,time32(NULL),tmp));
sprintf(tmp, "%.*s", (int)(LEN_FDESC-strlen(fdesc)), argv[++j]);
SAFECOPY(fdesc, tmp);
SAFEPRINTF(fdesc, "%s ", unixtodstr(&scfg,(time32_t)fdate(str),tmp));
else if(mode&TODAYS_DATE)
SAFEPRINTF(fdesc, "%s ", unixtodstr(&scfg,time32(NULL),tmp));
j++;
SAFECAT(fdesc, argv[j]);
l=(long)flength(str);
if(l==-1) {
printf("%s not found.\n",str);
......
......@@ -376,7 +376,7 @@ int main(int argc, char **argv)
exit(1);
}
else {
strcpy(dir,argv[i]);
SAFECOPY(dir,argv[i]);
backslash(dir);
}
}
......
......@@ -3458,7 +3458,7 @@ int main(int argc, char **argv)
puts(usage);
bail(1); }
else
sprintf(src,"%.*s",(int)(sizeof(src)-5),argv[i]); /* leave room for '.src' to be appended */
SAFECOPY(src, argv[i]);
if(show_banner)
printf(banner,PLATFORM_DESC,revision);
......@@ -3474,12 +3474,12 @@ int main(int argc, char **argv)
*p=0; /* Truncate off the src filename */
}
if(getfext(src)==NULL)
strcat(src,".src");
SAFECAT(src,".src");
SAFECOPY(bin_file,src);
if((p=getfext(bin_file))!=NULL)
*p=0;
strcat(bin_file,".bin");
SAFECAT(bin_file,".bin");
if(output_dir[0]) {
p=getfname(bin_file);
......
/* Utility to create list of files from Synchronet file directories */
/* DEPRECATED: use filelist.js instead */
/* Default list format is FILES.BBS, but file size, uploader, upload date */
/* and other information can be included. */
......@@ -55,31 +57,18 @@ int lprintf(int level, const char *fmat, ...)
return(chcount);
}
void stripctrlz(char *str)
{
char tmp[1024];
int i,j,k;
k=strlen(str);
for(i=j=0;i<k;i++)
if(str[i]!=0x1a)
tmp[j++]=str[i];
tmp[j]=0;
strcpy(str,tmp);
}
char* byteStr(unsigned long value)
{
static char tmp[128];
if(value>=(1024*1024*1024))
sprintf(tmp, "%5.1fG", value/(1024.0*1024.0*1024.0));
SAFEPRINTF(tmp, "%5.1fG", value/(1024.0*1024.0*1024.0));
else if(value>=(1024*1024))
sprintf(tmp, "%5.1fM", value/(1024.0*1024.0));
SAFEPRINTF(tmp, "%5.1fM", value/(1024.0*1024.0));
else if(value>=1024)
sprintf(tmp, "%5.1fK", value/1024.0);
SAFEPRINTF(tmp, "%5.1fK", value/1024.0);
else
sprintf(tmp, "%5luB", value);
SAFEPRINTF(tmp, "%5luB", value);
return tmp;
}
......@@ -234,7 +223,8 @@ int main(int argc, char **argv)
printf("\nDirectory internal code must follow -not parameter.\n");
exit(1);
}
sprintf(not[nots++],"%.8s",argv[i]);
SAFECOPY(not[nots], argv[i]);
nots++;
}
else if(!stricmp(argv[i],"-all")) {
if(dirnum!=-1) {
......@@ -343,14 +333,14 @@ int main(int argc, char **argv)
,/* filespec: */pattern, /* time: */t, file_detail_extdesc, scfg.dir[i]->sort, &file_count);
if(misc&AUTO) {
sprintf(str,"%sFILES.BBS",scfg.dir[i]->path);
SAFEPRINTF(str,"%sFILES.BBS",scfg.dir[i]->path);
if((out=fopen(str, omode)) == NULL) {
perror(str);
exit(1);
}
}
if(misc&HDR) {
sprintf(fname,"%-*s %-*s Files: %4lu"
safe_snprintf(fname, sizeof(fname), "%-*s %-*s Files: %4lu"
,LEN_GSNAME,scfg.lib[scfg.dir[i]->lib]->sname
,LEN_SLNAME,scfg.dir[i]->lname, (ulong)smb.status.total_files);
fprintf(out,"%s\n",fname);
......@@ -400,7 +390,7 @@ int main(int argc, char **argv)
}
if(misc&MINUS) {
sprintf(str,"%s%s",scfg.dir[i]->path,file.name);
SAFEPRINTF2(str,"%s%s",scfg.dir[i]->path,file.name);
if(!fexistcase(str))
fputc('-',out);
else
......@@ -411,8 +401,7 @@ int main(int argc, char **argv)
desc_off++;
if(misc&DFD) {
// TODO: Fix to support alt-file-paths:
sprintf(str,"%s%s",scfg.dir[i]->path,file.name);
SAFEPRINTF2(str,"%s%s",scfg.dir[i]->path,file.name);
desc_off += fprintf(out,"%s ",unixtodstr(&scfg,(time32_t)fdate(str),str));
}
......
......@@ -4329,6 +4329,13 @@ void node_thread(void* arg)
sbbs->clearvars(&sbbs->main_csi);
sbbs->main_csi.length=(long)filelength(file);
if(sbbs->main_csi.length < 1) {
close(file);
sbbs->errormsg(WHERE,ERR_LEN, str, sbbs->main_csi.length);
sbbs->hangup();
break;
}
if((sbbs->main_csi.cs=(uchar *)malloc(sbbs->main_csi.length))==NULL) {
close(file);
sbbs->errormsg(WHERE,ERR_ALLOC,str,sbbs->main_csi.length);
......
......@@ -398,12 +398,12 @@ void printnodedat(int number, node_t node)
hour=12;
else
hour=(node.aux/60)-12;
strcpy(mer,"pm"); }
SAFECOPY(mer,"pm"); }
else {
if((node.aux/60)==0) /* 12 midnite */
hour=12;
else hour=node.aux/60;
strcpy(mer,"am"); }
SAFECOPY(mer,"am"); }
printf(" ETA %02d:%02d %s"
,hour,node.aux-((node.aux/60)*60),mer); }
break; }
......@@ -504,17 +504,17 @@ int main(int argc, char **argv)
printf("This environment variable must be set to your CTRL directory.");
printf("\nExample: SET SBBSCTRL=/sbbs/ctrl\n");
exit(1); }
sprintf(ctrl_dir,"%.40s",p);
SAFECOPY(ctrl_dir, p);
if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
&& ctrl_dir[strlen(ctrl_dir)-1]!='/')
strcat(ctrl_dir,"/");
sprintf(str,"%snode.dab",ctrl_dir);
SAFEPRINTF(str,"%snode.dab",ctrl_dir);
if((nodefile=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
printf("\7\nError %d opening %s.\n",errno,str);
exit(1); }
sprintf(str,"%snode.exb",ctrl_dir);
SAFEPRINTF(str,"%snode.exb",ctrl_dir);
nodeexb=sopen(str,O_RDWR|O_BINARY,SH_DENYNO);
sys_nodes=(int)(filelength(nodefile)/sizeof(node_t));
......
......@@ -46,11 +46,11 @@ for(i=1;i<argc;i++)
if(!stricmp(argv[i],"/P"))
pause=1;
else
strcpy(dir,argv[1]);
SAFECOPY(dir,argv[1]);
if(!dir[0]) {
p=getenv("SBBSCTRL");
if(p!=NULL)
strcpy(dir,p); }
SAFECOPY(dir,p); }
backslash(dir);
......
......@@ -1002,6 +1002,13 @@ void packmsgs(ulong packable)
printf("Analyzing data blocks...\n");
length=filelength(fileno(smb.sda_fp));
if(length < 0) {
printf("\r!ERROR %d getting %s SDA file length.\n\n", errno, smb.file);
smb_close_ha(&smb);
smb_close_da(&smb);
smb_unlocksmbhdr(&smb);
return;
}
fseek(smb.sda_fp,0L,SEEK_SET);
for(l=m=0;l<length;l+=2) {
......@@ -1016,6 +1023,13 @@ void packmsgs(ulong packable)
printf("\rAnalyzing header blocks...\n");
length=filelength(fileno(smb.sha_fp));
if(length < 0) {
printf("\r!ERROR %d getting %s SHA file length.\n\n", errno, smb.file);
smb_close_ha(&smb);
smb_close_da(&smb);
smb_unlocksmbhdr(&smb);
return;
}
fseek(smb.sha_fp,0L,SEEK_SET);
for(l=n=0;l<length;l++) {
......@@ -1059,6 +1073,13 @@ void packmsgs(ulong packable)
printf("Analyzing %s\n",smb.file);
length=filelength(fileno(smb.shd_fp));
if(length < 0) {
printf("\r!ERROR %d getting %s SHD file length.\n\n", errno, smb.file);
smb_close_ha(&smb);
smb_close_da(&smb);
smb_unlocksmbhdr(&smb);
return;
}
m=n=0;
for(l=smb.status.header_offset;l<length;l+=size) {
printf("\r%2lu%% ",(long)(100.0/((float)length/l)));
......@@ -1852,7 +1873,7 @@ int main(int argc, char **argv)
,beep,i,smb.last_error,smb.file);
continue;
}
if(!filelength(fileno(smb.shd_fp))) {
if(filelength(fileno(smb.shd_fp)) < 1) {
if(!create) {
printf("Empty\n");
smb_close(&smb);
......
......@@ -302,23 +302,26 @@ void sbbs_t::sof(char *fname, char *answers, long len)
int file;
long length,l=0,m,a=0;
*answers = '\0';
sprintf(str,"%s%s.sif",cfg.text_dir,fname);
if((file=nopen(str,O_RDONLY))==-1) {
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
answers[0]=0;
return;
}
length=(long)filelength(file);
if(length < 0) {
close(file);
errormsg(WHERE, ERR_LEN, str, length);
return;
}
if((buf=(char *)calloc(length + 1, 1))==0) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,length);
answers[0]=0;
return;
}
if(lread(file,buf,length)!=length) {
close(file);
errormsg(WHERE,ERR_READ,str,length);
answers[0]=0;
free(buf);
return;
}
......
......@@ -686,6 +686,10 @@ int sbbs_t::searchup(char *search,int usernum)
return(usernum);
flen=(long)filelength(file);
if(flen < 0) {
close(file);
return usernum;
}
lseek(file,(long)((long)usernum*U_LEN),0);
while((i*U_LEN)<=(ulong)flen) {
......