From dabcb8fe607bb88116e39a7448f6daff77f29520 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 26 Jan 2011 23:37:48 +0100 Subject: [PATCH] Release 0.95.11, patches by Scott Street. Netmail nodelist sysop lookup added and some fixes --- ChangeLog | 17 +++++++++ configure | 6 ++-- configure.ac | 6 ++-- lang/Language.xref | 2 ++ lang/source.de | 2 ++ lang/source.en | 2 ++ lang/source.es | 2 ++ lang/source.fr | 2 ++ lang/source.gl | 2 ++ lang/source.nl | 2 ++ lang/source.zh | 2 ++ lib/nntp.c | 5 ++- lib/nodelist.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++ lib/nodelist.h | 12 ++++++- mbsebbs/dispfile.c | 5 ++- mbsebbs/email.c | 11 +++--- mbsebbs/fsedit.c | 10 +++--- mbsebbs/mail.c | 41 ++++++++++++++++++---- mbsebbs/msgutil.c | 5 ++- mbsebbs/oneline.c | 5 ++- mbsetup/m_lang.c | 9 +++-- mbtask/taskchat.c | 15 ++++---- 22 files changed, 201 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d475a94..ffc499b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +v0.95.11 14-Jan-2011 (patches by Scott Street). + + mbselib: + Fixed memory corruption error in mbnntp. + Added sysop in nodelist search function. + + mbsebbs: + Fixed several (possible) buffer overflows, some serious ones. + Added lookup sysop in nodelist for netmail messages. + + mbtask: + Fixed several (possible) buffer overflows. + + lang: + Added language prompts 480 and 481. + + v0.95.10 26-Aug-2010 (released by Vince Coen). mbsetup: diff --git a/configure b/configure index 6747140a..2b0d47aa 100755 --- a/configure +++ b/configure @@ -2274,10 +2274,10 @@ SUBDIRS="lib mbcico mbfido mbmon mbsebbs mbutils mbnntp mbtask mbsetup unix lang PACKAGE="mbsebbs" MAJOR="0" MINOR="95" -REVISION="10" +REVISION="11" VERSION="$MAJOR.$MINOR.$REVISION" -COPYRIGHT="Copyright (C) 1997-2010 Michiel Broek, All Rights Reserved" -SHORTRIGHT="Copyright (C) 1997-2010 M. Broek" +COPYRIGHT="Copyright (C) 1997-2011 Michiel Broek, All Rights Reserved" +SHORTRIGHT="Copyright (C) 1997-2011 M. Broek" GROUP="bbs" OWNER="mbse" ROWNER="`id -un root`" diff --git a/configure.ac b/configure.ac index 2a2ee42a..4243215d 100644 --- a/configure.ac +++ b/configure.ac @@ -12,10 +12,10 @@ AC_SUBST(SUBDIRS) PACKAGE="mbsebbs" MAJOR="0" MINOR="95" -REVISION="10" +REVISION="11" VERSION="$MAJOR.$MINOR.$REVISION" -COPYRIGHT="Copyright (C) 1997-2010 Michiel Broek, All Rights Reserved" -SHORTRIGHT="Copyright (C) 1997-2010 M. Broek" +COPYRIGHT="Copyright (C) 1997-2011 Michiel Broek, All Rights Reserved" +SHORTRIGHT="Copyright (C) 1997-2011 M. Broek" GROUP="bbs" OWNER="mbse" ROWNER="`id -un root`" diff --git a/lang/Language.xref b/lang/Language.xref index 7291b9bb..f5253d00 100644 --- a/lang/Language.xref +++ b/lang/Language.xref @@ -478,3 +478,5 @@ 477 mail.c |Use your alias ( 478 mail.c YN|) to post this message [Y/n]: 479 mail.c |No more areas with unread messages +480 mail.c |Addresse not in Nodelist +481 mail.c |Found Addresse in Nodelist diff --git a/lang/source.de b/lang/source.de index f5e5dec3..ec04c6d2 100644 --- a/lang/source.de +++ b/lang/source.de @@ -478,3 +478,5 @@ JN|Datei anhaengen [j/N]: |Moechten Sie Ihren Aliasnamen ( JN|) als Absender verwenden [J/n] |Keine weitere Bereiche mit ungelesenen Nachrichten +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lang/source.en b/lang/source.en index 9fdbb463..4e090695 100644 --- a/lang/source.en +++ b/lang/source.en @@ -478,3 +478,5 @@ YN|Attach file [y/N]: |Use your alias ( YN|) to post this message [Y/n]: |No more areas with unread messages +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lang/source.es b/lang/source.es index 1f720643..3bb7c543 100644 --- a/lang/source.es +++ b/lang/source.es @@ -478,3 +478,5 @@ YN|Adjuntar fichero [s/N]: |Usar tu alias ( SN|) para este mensaje [S/n]: |No hay mas areas con mensajes no leidos +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lang/source.fr b/lang/source.fr index 5bb70fde..ddf4befe 100644 --- a/lang/source.fr +++ b/lang/source.fr @@ -478,3 +478,5 @@ YN|Attach file [y/N]: |Use your alias ( YN|) to post this message [Y/n]: |No more areas with unread messages +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lang/source.gl b/lang/source.gl index 7f639425..0d5ae099 100644 --- a/lang/source.gl +++ b/lang/source.gl @@ -478,3 +478,5 @@ YN|Adxuntar ficheiro [s/N]: |¨Queres usa-lo alias ( SN|) nesta mensaxe? [S/n]: |Non hai mais  reas con mensaxes sen ler. +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lang/source.nl b/lang/source.nl index 8d8ac1f6..c9bf1337 100644 --- a/lang/source.nl +++ b/lang/source.nl @@ -478,3 +478,5 @@ JN|Bestand meesturen [j/N]: |Use your alias ( YN|) to post this message [Y/n]: |Geen gebieden meer met ongelezen berichten +|Geadresseerde niet in de Nodelijst +|Geadresseerde gevonden in de nodelijst diff --git a/lang/source.zh b/lang/source.zh index 8498fe8b..1280a969 100644 --- a/lang/source.zh +++ b/lang/source.zh @@ -478,3 +478,5 @@ YN|Attach file [y/N]: |Use your alias ( YN|) to post this message [Y/n]: |No more areas with unread messages +|Addresse not in Nodelist +|Found Addresse in Nodelist diff --git a/lib/nntp.c b/lib/nntp.c index 85e98278..0557429f 100644 --- a/lib/nntp.c +++ b/lib/nntp.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: nntp.c,v 1.16 2008/12/28 12:20:14 mbse Exp $ * Purpose ...............: MBSE BBS Internet Library * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -249,7 +248,7 @@ int nntp_cmd(char *cmd, int resp) if (strncmp(p, rsp, strlen(rsp))) { WriteError("NNTP> %s", cmd); WriteError("NNTP< %s", p); - memset(&resp, 0, sizeof(rsp)); + memset(rsp, 0, sizeof(rsp)); strncpy(rsp, p, 3); return atoi(rsp); } diff --git a/lib/nodelist.c b/lib/nodelist.c index cc70476a..0deeb415 100644 --- a/lib/nodelist.c +++ b/lib/nodelist.c @@ -1162,3 +1162,89 @@ retdummy: } + +node_list *searchSysop( char *SysopName ) +{ + char nodeuserpath[256]; + FILE *fp; + char fixedSysopName[36]; + nlusr nluEntry; + faddr addr; + node_list *result; + node *nlEntry; + + Syslog('n', "searchSysop: Arg(%s) started", SysopName ); + + result = NULL; + snprintf(nodeuserpath, 256, "%s/%s", CFG.nodelists, "node.users"); + if ((fp = fopen(nodeuserpath, "r")) == NULL) { + WriteError("$Can't open %s", nodeuserpath); + return NULL; + } + + /* + * fixup incoming sysop name to have _ for space + */ + memset( fixedSysopName, 0, 36 ); + int i; + for ( i=0; iname, nlEntry->location); + + node_list *thisresult = result; + if (thisresult == NULL) { + result = malloc( sizeof(node_list)); + result->next = NULL; + thisresult = result; + } else { + while ( thisresult->next != NULL ){ + thisresult = thisresult->next; + } + thisresult->next = malloc( sizeof(node_list)); + thisresult = thisresult->next; + thisresult->next = NULL; + } + thisresult->addr.zone = nlEntry->addr.zone; + thisresult->addr.net = nlEntry->addr.net; + thisresult->addr.node = nlEntry->addr.node; + thisresult->addr.point = nlEntry->addr.point; + strcpy( thisresult->Sysop, nlEntry->sysop ); + strcpy( thisresult->Location, nlEntry->location); + strcpy( thisresult->Name, nlEntry->name ); + + } + if ( nluEntry.user[0] > fixedSysopName[0] ) { // Since list is sorted, abort once we get names that start after this one + break; + } + } + fclose( fp ); + + Syslog('n', "searchSysop: Arg(%s) ended", SysopName ); + return result; +} + + diff --git a/lib/nodelist.h b/lib/nodelist.h index 0fe968cd..dba1f6c0 100644 --- a/lib/nodelist.h +++ b/lib/nodelist.h @@ -41,6 +41,16 @@ typedef struct _node { +typedef struct _node_list { + struct _node_list *next; + faddr addr; + char Name[80]; + char Sysop[80]; + char Location[80]; +} node_list; + + + /* * Memory array structures read from nodelist.conf */ @@ -122,7 +132,7 @@ nodelist_service *nl_service; int initnl(void); void deinitnl(void); node *getnlent(faddr *); - +node_list *searchSysop(char *); #endif diff --git a/mbsebbs/dispfile.c b/mbsebbs/dispfile.c index 40f76795..92d2c0b0 100644 --- a/mbsebbs/dispfile.c +++ b/mbsebbs/dispfile.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: dispfile.c,v 1.26 2007/09/02 15:04:36 mbse Exp $ * Purpose ...............: Display ANSI/ASCII textfiles * ***************************************************************************** - * Copyright (C) 1997-2007 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -314,7 +313,7 @@ int DisplayFile(char *filename) break; default: snprintf(tmp1, sizeof(tmp1)-1, "%c", buf[x]); - strncat(out, tmp1, sizeof(out)); + strncat(out, tmp1, sizeof(out)-1); } /* switch */ } /* for */ diff --git a/mbsebbs/email.c b/mbsebbs/email.c index 80e6c677..b47ee03c 100644 --- a/mbsebbs/email.c +++ b/mbsebbs/email.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: email.c,v 1.35 2008/02/12 19:59:45 mbse Exp $ * Purpose ...............: Internet email * ***************************************************************************** - * Copyright (C) 1997-2008 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -438,7 +437,7 @@ int Read_a_Email(unsigned int Num) * a reply will be made. */ if (strncasecmp(p, "\001Message-id: ", 13) == 0) { - snprintf(Msg.Msgid, 101, "%s", p+13); + snprintf(Msg.Msgid, sizeof(Msg.Msgid), "%s", p+13); Syslog('m', "Stored Msgid \"%s\"", Msg.Msgid); } if (Kludges) { @@ -747,9 +746,9 @@ void Reply_Email(int IsReply) Line = 1; Msg_New(); - snprintf(Msg.Replyid, 101, "%s", msgid); - snprintf(Msg.ReplyTo, 101, "%s", replyto); - snprintf(Msg.ReplyAddr, 101, "%s", replyaddr); + snprintf(Msg.Replyid, sizeof(Msg.Replyid), "%s", msgid); + snprintf(Msg.ReplyTo, sizeof(Msg.ReplyTo), "%s", replyto); + snprintf(Msg.ReplyAddr, sizeof(Msg.ReplyAddr), "%s", replyaddr); /* From : */ pout(YELLOW, BLACK, (char *) Language(209)); diff --git a/mbsebbs/fsedit.c b/mbsebbs/fsedit.c index 24248f2a..e316a31a 100644 --- a/mbsebbs/fsedit.c +++ b/mbsebbs/fsedit.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: fsedit.c,v 1.28 2007/08/25 18:32:08 mbse Exp $ * Purpose ...............: FullScreen Message editor. * ***************************************************************************** - * Copyright (C) 1997-2007 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -395,8 +394,11 @@ int FsWordWrap() if ((WCol == 80) && (Col >= WCol)) WCol = strlen((char *)tmpLine)+1; else { - if (tmpLine[strlen((char *)tmpLine)] != ' ') - snprintf((char *)tmpLine + strlen((char *)tmpLine), 1, " "); + if (tmpLine[strlen((char *)tmpLine)] != ' '){ + int tmpLength=strlen((char *)tmpLine); + tmpLine[tmpLength] = ' '; + tmpLine[tmpLength+1] = '\0'; + } WCol = strlen((char *)tmpLine); } snprintf(Message[CurRow+1], TEXTBUFSIZE +1, "%s", strcat((char *)tmpLine, Message[CurRow+1])); diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 99cdcb09..3ded5b24 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -1,11 +1,10 @@ /***************************************************************************** * - * $Id: mail.c,v 1.69 2008/02/12 19:59:45 mbse Exp $ * Purpose ...............: Message reading and writing. * Todo ..................: Implement message groups. * ***************************************************************************** - * Copyright (C) 1997-2008 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -503,8 +502,38 @@ void Post_Msg() } else if (msgs.Type == NETMAIL) { x = FALSE; Enter(1); - pout(YELLOW, BLACK, (char *)"Address : "); FidoNode = calloc(61, sizeof(char)); + /* + * Search for Name in Sysop Index of Nodelist + */ + node_list *nodesSysop; + node_list *thisNode; + node_list *prevNode; + + if ( NULL ==( nodesSysop=searchSysop(Msg.To) )){ + snprintf(msg, 81, "%s\r\n\n", (char*)Language(480)); + pout(RED, BLACK, msg); + } else { + snprintf(msg, 81, "%s\r\n\n", (char*)Language(481)); + pout(GREEN, BLACK, msg); + thisNode = nodesSysop; + while ( thisNode != NULL ){ + snprintf(msg, 81, "(%d:%d/%d:%d) %s @ %s\r\n", + thisNode->addr.zone, thisNode->addr.net, + thisNode->addr.node, thisNode->addr.point, + thisNode->Name, thisNode->Location); + pout(CYAN, BLACK, msg); + prevNode = thisNode; + thisNode = thisNode->next; + free( prevNode ); + } + pout(YELLOW, BLACK, (char *)"\r\n"); + } + /* + * End Search + */ + + pout(YELLOW, BLACK, (char *)"Address : "); colour(CFG.MsgInputColourF, CFG.MsgInputColourB); GetstrC(FidoNode, 60); @@ -1610,9 +1639,9 @@ void Reply_Msg(int IsReply) Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Msg_New(); - strncpy(Msg.Replyid, msgid, 101); - strncpy(Msg.ReplyTo, replyto, 101); - strncpy(Msg.ReplyAddr, replyaddr, 101); + strncpy(Msg.Replyid, msgid, sizeof(Msg.Replyid)); + strncpy(Msg.ReplyTo, replyto, sizeof(Msg.ReplyTo)); + strncpy(Msg.ReplyAddr, replyaddr, sizeof(Msg.ReplyAddr)); /* From : */ if (Alias_Option()) { diff --git a/mbsebbs/msgutil.c b/mbsebbs/msgutil.c index 149c5269..534c9340 100644 --- a/mbsebbs/msgutil.c +++ b/mbsebbs/msgutil.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: msgutil.c,v 1.24 2005/10/11 20:49:48 mbse Exp $ * Purpose ...............: Utilities for message handling. * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -160,7 +159,7 @@ void Add_Headkludges(faddr *dest, int IsReply) time_t tt; faddr *Node; - temp = calloc(128, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); switch (msgs.Type) { case LOCALMAIL: Msg.Localmail = TRUE; diff --git a/mbsebbs/oneline.c b/mbsebbs/oneline.c index f9c78c07..ec9f4297 100644 --- a/mbsebbs/oneline.c +++ b/mbsebbs/oneline.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: oneline.c,v 1.15 2007/02/26 14:48:23 mbse Exp $ * Purpose ...............: Oneliner functions. * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -196,7 +195,7 @@ char *Oneliner_Get() /* * Get a random oneliner */ - sFileName = calloc(128, sizeof(char)); + sFileName = calloc(PATH_MAX, sizeof(char)); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT")); if ((pOneline = fopen(sFileName, "r+")) == NULL) { diff --git a/mbsetup/m_lang.c b/mbsetup/m_lang.c index 25ff216b..0039e3d7 100644 --- a/mbsetup/m_lang.c +++ b/mbsetup/m_lang.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: m_lang.c,v 1.25 2007/02/17 12:14:27 mbse Exp $ * Purpose ...............: Setup Languages. * ***************************************************************************** - * Copyright (C) 1997-2007 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -126,7 +125,7 @@ void UpgradeLanguage(char *name, char *lc) WriteError("$Can't move %s to %s", lang.xMenuPath, temp); } else { Syslog('+', "Moved %s to %s", lang.xMenuPath, temp); - snprintf(lang.xMenuPath, PATH_MAX, temp); + snprintf(lang.xMenuPath, sizeof(lang.xMenuPath), temp); } } else { Syslog('+', "%s already upgraded", temp); @@ -140,7 +139,7 @@ void UpgradeLanguage(char *name, char *lc) WriteError("$Can't move %s to %s", lang.xTextPath, temp); } else { Syslog('+', "Moved %s to %s", lang.xTextPath, temp); - snprintf(lang.xTextPath, PATH_MAX, temp); + snprintf(lang.xTextPath, sizeof(lang.xTextPath), temp); } } else { Syslog('+', "%s already upgraded", temp); @@ -154,7 +153,7 @@ void UpgradeLanguage(char *name, char *lc) WriteError("$Can't move %s to %s", lang.xMacroPath, temp); } else { Syslog('+', "Moved %s to %s", lang.xMacroPath, temp); - snprintf(lang.xMacroPath, PATH_MAX, temp); + snprintf(lang.xMacroPath, sizeof(lang.xMacroPath), temp); } } else { Syslog('+', "%s already upgraded", temp); diff --git a/mbtask/taskchat.c b/mbtask/taskchat.c index fd45c5ab..e1332882 100644 --- a/mbtask/taskchat.c +++ b/mbtask/taskchat.c @@ -1,10 +1,9 @@ /***************************************************************************** * - * $Id: taskchat.c,v 1.63 2006/05/27 13:19:53 mbse Exp $ * Purpose ...............: mbtask - chat server * ***************************************************************************** - * Copyright (C) 1997-2006 + * Copyright (C) 1997-2011 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -455,23 +454,23 @@ void chat_connect_r(char *data, char *buf) * Now put welcome message into the ringbuffer and report success. */ temp = calloc(81, sizeof(char)); - snprintf(temp, 200, "MBSE BBS v%s chat server; type /help for help", VERSION); + snprintf(temp, 80, "MBSE BBS v%s chat server; type /help for help", VERSION); system_msg(usr_list[i].pid, temp); - snprintf(temp, 200, "Welcome to the Internet BBS Chat Network"); + snprintf(temp, 80, "Welcome to the Internet BBS Chat Network"); system_msg(usr_list[i].pid, temp); - snprintf(temp, 200, "Current connected servers:"); + snprintf(temp, 80, "Current connected servers:"); system_msg(usr_list[i].pid, temp); for (j = 0; j < MAXIBC_SRV; j++) { if (strlen(srv_list[j].server)) { - snprintf(temp, 200, " %d user%s at '%s'", + snprintf(temp, 80, " %d user%s at '%s'", srv_list[j].users, (srv_list[j].users == 1) ? " ":"s", srv_list[j].fullname); system_msg(usr_list[i].pid, temp); count += srv_list[j].users; } } - snprintf(temp, 200, "There %s %d user%s connected", (count != 1)?"are":"is", count, (count != 1)?"s":""); + snprintf(temp, 80, "There %s %d user%s connected", (count != 1)?"are":"is", count, (count != 1)?"s":""); system_msg(usr_list[i].pid, temp); - snprintf(buf, 200, "100:0;"); + snprintf(buf, 80, "100:0;"); free(realname); free(nick); free(temp);