...
 
Commits (3)
  • Rob Swindell's avatar
    Don't log errno info for ERR_CHK errormsg() calls · 48f73ca1
    Rob Swindell authored
    The errno (global error number) information is not relevant for any sbbs "checking" type errors.
    Also, use safe_strerror() for thread-safe errno descriptions.
    48f73ca1
  • Rob Swindell's avatar
    Comment header block update. Nothing else. · 6e451021
    Rob Swindell authored
    6e451021
  • Rob Swindell's avatar
    Fix 18 year old bug with updating/appending existing REP packets · faadb5b9
    Rob Swindell authored
    18 years, 10 months ago I introduced a bug whereby .MSG files in outgoing REP packets were *always* truncated before newly-exported messages were added. Even though the log message would say "Updating /path/to/HUBID.REP" (rather than the usual "Creating ...") it was actually truncating the .MSG file, thus discarding any existing messages that were not previously successfully sent (!). I'm not sure what the problem was I was trying to solve at the time (some "Unix .rep creation bug") - but the change I made at the time was most definitely was not the correct fix. :-(
    
    How I noticed this problem was the HEADERS.DAT Conference Number check I added to qwk_parse_header_list() back in August of 2019. I've been catching/logging those errors here on Vertrauen and collecting *.rep.bad files from occasional QWKnet node-submitted REP packets, but I didn't look into the cause until today: the HEADERS.DAT and VOTING.DAT files were being correctly appended even though the .MSG file was being truncated, so the files would be out-of-sync and this was the root-cause of the crossed-up message bodies/headers seen on DOVE-Net a year or more ago and apparently also the cause of occasionally lost messages from QWKnet (e.g. DOVE-Net) nodes.
    
    To trigger this bug from the node side, you'd have to create a REP packet with one or more message in it and then fail to send it to your hub (e.g. VERT), for any reason. And then when you attempt another pack/call-out, the previously packed messages would be lost and the HEADERS.DAT file would contain stale/out-of-sync information. 
    
    To simplify things, I'm now just using fopen(..., "ab") (append, binary) - fnopen() should not be needed when opening files in the temp_dir. In append mode, no subsequent fseek(..., SEEK_END) should be needed, so don't do that. And use fprintf() for its intended purpose.
    faadb5b9
/* Synchronet log file routines */
/* $Id: logfile.cpp,v 1.69 2020/08/08 19:32:30 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -239,21 +225,28 @@ void sbbs_t::errormsg(int line, const char* function, const char *src, const cha
,long access, const char *extinfo)
{
char str[2048];
char errno_str[128];
char errno_info[256] = "";
/* prevent recursion */
if(errormsg_inside)
return;
errormsg_inside=true;
safe_snprintf(str,sizeof(str),"ERROR %d (%s) "
#ifdef _WIN32
"(WinError %u) "
#endif
if(strcmp(action, ERR_CHK) != 0)
safe_snprintf(errno_info, sizeof(errno_info), "%d (%s) "
#ifdef _WIN32
"(WinError %u) "
#endif
,errno, safe_strerror(errno, errno_str, sizeof(errno_str))
#ifdef _WIN32
,GetLastError()
#endif
);
safe_snprintf(str,sizeof(str),"ERROR %s"
"in %s line %u (%s) %s \"%s\" access=%ld %s%s"
,errno,STRERROR(errno)
#ifdef _WIN32
,GetLastError()
#endif
,errno_info
,src, line, function, action, object, access
,extinfo==NULL ? "":"info="
,extinfo==NULL ? "":extinfo);
......
/* logout.cpp */
/* Synchronet user logout routines */
/* $Id: logout.cpp,v 1.33 2019/05/05 10:54:22 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......
/* Synchronet QWK reply (REP) packet creation routine */
/* $Id: pack_rep.cpp,v 1.51 2020/04/11 04:01:36 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -46,7 +32,7 @@ bool sbbs_t::pack_rep(uint hubnum)
char tmp[MAX_PATH+1],tmp2[MAX_PATH+1];
char hubid_upper[LEN_QWKID+1];
char hubid_lower[LEN_QWKID+1];
int file,mode;
int mode;
uint i,j,k;
long msgcnt,submsgs,packedmail,netfiles=0,deleted;
uint32_t u;
......@@ -82,17 +68,14 @@ bool sbbs_t::pack_rep(uint hubnum)
/*************************************************/
SAFEPRINTF2(str,"%s%s.MSG",cfg.temp_dir,hubid_upper);
fexistcase(str);
if((rep=fnopen(&file,str,O_CREAT|O_WRONLY|O_TRUNC))==NULL) {
errormsg(WHERE,ERR_CREATE,str,O_CREAT|O_WRONLY|O_TRUNC);
return(false);
if((rep=fopen(str, "ab"))==NULL) {
errormsg(WHERE, ERR_CREATE, str, 0);
return false;
}
if(filelength(file)<1) { /* New REP packet */
SAFEPRINTF2(str,"%-*s"
,QWK_BLOCK_LEN,hubid_upper); /* So write header */
fwrite(str,QWK_BLOCK_LEN,1,rep);
if(ftell(rep) < 1) { /* New REP packet */
fprintf(rep, "%-*s"
,QWK_BLOCK_LEN, hubid_upper); /* So write header */
}
fseek(rep,0L,SEEK_END);
if(!(cfg.qhub[hubnum]->misc&QHUB_NOHEADERS)) {
SAFEPRINTF(str,"%sHEADERS.DAT",cfg.temp_dir);
fexistcase(str);
......