Skip to content
Snippets Groups Projects
Commit 1ba0e00e authored by rswindell's avatar rswindell
Browse files

Better FTP temp filenames - use meaningful extensions: e.g. lst, html.

parent 88f9dc22
No related branches found
No related tags found
No related merge requests found
......@@ -2280,10 +2280,11 @@ static BOOL badlogin(SOCKET sock, ulong* login_attempts)
return(FALSE);
}
static char* ftp_tmpfname(char* str, SOCKET sock)
static char* ftp_tmpfname(char* fname, char* ext, SOCKET sock)
{
safe_snprintf(str,MAX_PATH,"%sSBBS_FTP.%u.%u.tx",scfg.temp_dir,getpid(),sock);
return(str);
safe_snprintf(fname,MAX_PATH,"%sSBBS_FTP.%x%x%x%lx.%s"
,scfg.temp_dir,getpid(),sock,rand(),clock(),ext);
return(fname);
}
static void ctrl_thread(void* arg)
......@@ -3041,7 +3042,7 @@ static void ctrl_thread(void* arg)
strcat(local_dir,"/");
if(!strnicmp(cmd, "LIST", 4) || !strnicmp(cmd, "NLST", 4)) {
if((fp=fopen(ftp_tmpfname(fname,sock),"w+b"))==NULL) {
if((fp=fopen(ftp_tmpfname(fname,"lst",sock),"w+b"))==NULL) {
lprintf(LOG_ERR,"%04d !ERROR %d opening %s",sock,errno,fname);
sockprintf(sock, "451 Insufficient system storage");
continue;
......@@ -3343,7 +3344,7 @@ static void ctrl_thread(void* arg)
if(*filespec==0)
filespec="*";
if((fp=fopen(ftp_tmpfname(fname,sock),"w+b"))==NULL) {
if((fp=fopen(ftp_tmpfname(fname,"lst",sock),"w+b"))==NULL) {
lprintf(LOG_ERR,"%04d !ERROR %d opening %s",sock,errno,fname);
sockprintf(sock, "451 Insufficient system storage");
continue;
......@@ -3736,7 +3737,7 @@ static void ctrl_thread(void* arg)
sockprintf(sock, "500 Size not available for dynamically generated files");
continue;
}
if((fp=fopen(ftp_tmpfname(fname,sock),"w+b"))==NULL) {
if((fp=fopen(ftp_tmpfname(fname,"ndx",sock),"w+b"))==NULL) {
lprintf(LOG_ERR,"%04d !ERROR %d opening %s",sock,errno,fname);
sockprintf(sock, "451 Insufficient system storage");
filepos=0;
......@@ -3940,7 +3941,7 @@ static void ctrl_thread(void* arg)
JS_SetProperty(js_cx, js_ftp, "extended_descriptions", &js_val);
#endif
if((fp=fopen(ftp_tmpfname(fname,sock),"w+b"))==NULL) {
if((fp=fopen(ftp_tmpfname(fname,"html",sock),"w+b"))==NULL) {
lprintf(LOG_ERR,"%04d !ERROR %d opening %s",sock,errno,fname);
sockprintf(sock, "451 Insufficient system storage");
filepos=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment