Commit ebc249ca authored by rswindell's avatar rswindell
Browse files

Fix issue with long filenames in file listings (e.g. files.bbs) as reported by

deepthaw.
Also, if there was only one line in the file listing, nothing would be
imported (now fixed).
parent b679ecff
/* addfiles.c */
/* Program to add files to a Synchronet file database */
/* $Id$ */
......@@ -8,7 +6,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -37,7 +35,7 @@
#include "sbbs.h"
#define ADDFILES_VER "3.02"
#define ADDFILES_VER "3.03"
scfg_t scfg;
......@@ -348,7 +346,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
,listpath,scfg.lib[scfg.dir[f.dir]->lib]->sname,scfg.dir[f.dir]->sname);
fgets(nextline,255,stream);
while(!feof(stream) && !ferror(stream)) {
do {
f.misc=0;
f.desc[0]=0;
strcpy(curline,nextline);
......@@ -360,10 +358,12 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
printf("%s\n",curline);
strcpy(fname,curline);
#if 0 /* Files without dots are valid on modern systems */
p=strchr(fname,'.');
if(!p || p==fname || p>fname+8) /* no dot or invalid dot location */
continue;
p=strchr(p,' ');
#endif
p=strchr(fname,' ');
if(p) *p=0;
else /* no space after filename? */
continue;
......@@ -372,6 +372,17 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
#endif
strcpy(fname,unpadfname(fname,tmp));
sprintf(filepath,"%s%s",cur_altpath ? scfg.altpath[cur_altpath-1]
: scfg.dir[f.dir]->path,fname);
#ifdef _WIN32
{
char shortpath[MAX_PATH+1];
GetShortPathName(filepath, shortpath, sizeof(shortpath));
SAFECOPY(fname, getfname(shortpath));
}
#endif
padfname(fname,f.name);
if(strcspn(f.name,"\\/|<>+[]:=\";,")!=strlen(f.name))
continue;
......@@ -394,9 +405,6 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
}
}
sprintf(filepath,"%s%s",cur_altpath ? scfg.altpath[cur_altpath-1]
: scfg.dir[f.dir]->path,fname);
if(mode&FILE_DATE) { /* get the file date and put into desc */
l=(time32_t)fdate(filepath);
unixtodstr(&scfg,l,f.desc);
......@@ -461,10 +469,14 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
if(sskip) l=atol(fname+sskip);
else {
l=flength(filepath);
if(l<1L) {
if(l<0L) {
printf("%s not found.\n",filepath);
continue;
}
if(l == 0L) {
printf("%s is a zero-0length file.\n",filepath);
continue;
}
}
if(mode&FILE_ID) {
......@@ -528,7 +540,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
if(mode&UL_STATS)
updatestats(l);
files++;
}
} while(!feof(stream) && !ferror(stream));
fclose(stream);
if(mode&DEL_LIST && !(mode&SYNC_LIST)) {
printf("\nDeleting %s\n",listpath);
......
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