diff --git a/mbsebbs/zmrecv.c b/mbsebbs/zmrecv.c index 7c537ac6..202e28b1 100644 --- a/mbsebbs/zmrecv.c +++ b/mbsebbs/zmrecv.c @@ -516,6 +516,21 @@ int procheader(char *Name) /* set default parameters and overrides */ openmode = (char *)"w"; + /* + * Check slashes in the name + */ + p = strrchr(Name,'/'); + if (p) { + p++; + if (!*p) { + /* alert - file name ended in with a / */ + Syslog('!', "%s: file name ends with a /, skipped: %s", protname(), Name); + return ERROR; + } + Name = p; + Syslog('z', "filename converted to \"%s\"", MBSE_SS(Name)); + } + Syslog('z', "zmanag=%d", zmanag); Syslog('z', "zconv=%d", zconv); @@ -537,10 +552,12 @@ int procheader(char *Name) Eofseen = FALSE; p = Name + 1 + strlen(Name); - // FIXME: Here we must add code that checks the Name for slashes, spaces and other - // illegal characters in the filename. - sscanf(p, "%ld%lo%o%o%d%d%d%d", &Bytesleft, &Modtime, &Filemode, &dummy, &dummy, &dummy, &dummy, &dummy); - strcpy(ctt, rfcdate(Modtime)); + if (*p) { /* file coming from Unix or DOS system */ + sscanf(p, "%ld%lo%o%o%d%d%d%d", &Bytesleft, &Modtime, &Filemode, &dummy, &dummy, &dummy, &dummy, &dummy); + strcpy(ctt, rfcdate(Modtime)); + } else { + Syslog('z', "File coming from a CP/M system"); + } Syslog('+', "%s: \"%s\" %ld bytes, %s mode %o", protname(), Name, Bytesleft, ctt, Filemode); if (curfile) diff --git a/mbsebbs/zmsend.c b/mbsebbs/zmsend.c index 5977cc3c..7ba731f5 100644 --- a/mbsebbs/zmsend.c +++ b/mbsebbs/zmsend.c @@ -213,7 +213,11 @@ static int sendzfile(char *rn) Syslog('+', "Zmodem: size %lu bytes, dated %s", (unsigned long)st.st_size, rfcdate(st.st_mtime)); gettimeofday(&starttime, &tz); - sprintf(txbuf,"%s %lu %lo %o 0 0 0", rn,(unsigned long)st.st_size, st.st_mtime+(st.st_mtime%2), st.st_mode); + /* + * Filemode is fixed to 100644, we don't care how it is stored in the filebase. + */ + sprintf(txbuf,"%s %lu %lo 100644 0 0 0", rn,(unsigned long)st.st_size, st.st_mtime+(st.st_mtime%2)); + Syslog('z', "txbuf \"%s\"", txbuf); bufl = strlen(txbuf); *(strchr(txbuf,' ')) = '\0'; /*hope no blanks in filename*/