From f0cd12e35149b38761b187f22794782b7ba9c0ff Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 8 Feb 2012 18:05:13 -0500 Subject: [PATCH] off-by-one fix in siteconfig --- webcit/siteconfig.c | 59 +++++++++++++++++++++++++++------------------ webcit/webcit.c | 8 +----- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 4038bd03f..2f3d91cb5 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -1,12 +1,20 @@ /* * Administrative screen for site-wide configuration + * + * Copyright (c) 1996-2011 by the citadel.org team + * + * This program is open source software. You can redistribute it and/or + * modify it under the terms of the GNU General Public License, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ - #include "webcit.h" #include "webserver.h" - HashList *ZoneHash = NULL; ConstStr ExpirePolicyString = {CStrOf(roompolicy) }; @@ -93,7 +101,6 @@ void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP) } - void LoadZoneFiles(void) { icalarray *zones; @@ -124,7 +131,7 @@ typedef struct _CfgMapping { int type; const char *Key; long len; -}CfgMapping; +} CfgMapping; #define CFG_STR 1 #define CFG_YES 2 @@ -197,8 +204,8 @@ CfgMapping ServerConfig[] = { {CFG_STR, HKEY("c_xmpp_s2s_port")}, {CFG_STR, HKEY("c_pop3_fetch")}, {CFG_STR, HKEY("c_pop3_fastest")}, - {CFG_YES , HKEY("c_spam_flag_only")}, - {CFG_YES , HKEY("c_guest_logins")} + {CFG_YES, HKEY("c_spam_flag_only")}, + {CFG_YES, HKEY("c_guest_logins")} }; @@ -226,30 +233,36 @@ void load_siteconfig(void) AppendImportantMessage(SKEY(Buf)); FreeStrBuf(&Buf); return; - } + i = 0; while (len = StrBuf_ServGetln(Buf), - (len >= 0) && - (i <= (sizeof(ServerConfig) / sizeof(CfgMapping))) && - ((len != 3) || strcmp(ChrPtr(Buf), "000"))) - { + (len >= 0) + && (i < (sizeof(ServerConfig) / sizeof(CfgMapping))) + && ((len != 3) || strcmp(ChrPtr(Buf), "000")) + ) { Put(Cfg, - ServerConfig[i].Key, - ServerConfig[i].len, - Buf, - HFreeStrBuf); + ServerConfig[i].Key, + ServerConfig[i].len, + Buf, + HFreeStrBuf + ); i++; - if (i <= sizeof(ServerConfig) / sizeof(CfgMapping)) + if (i <= sizeof(ServerConfig) / sizeof(CfgMapping)) { Buf = NewStrBuf(); - else - Buf = NULL; + } + else { + Buf = NULL; + } } - if (strcmp(ChrPtr(Buf), "000")!=0) + + if (strcmp(ChrPtr(Buf), "000") != 0) { - /* WHOOOOPSI??? burn the lines we don't understand */ - while ((len = StrBuf_ServGetln(Buf), - strcmp(ChrPtr(Buf), "000"))) {} + /* Discard config lines which we don't yet support */ + while ( (len = StrBuf_ServGetln(Buf), + strcmp(ChrPtr(Buf), "000")) + ) { + } AppendImportantMessage(_("WARNING: Failed to parse Server Config; do you run a to new citserver?"), -1); FreeStrBuf(&Buf); return; @@ -262,7 +275,7 @@ void load_siteconfig(void) -/** +/* * parse siteconfig changes */ void siteconfig(void) diff --git a/webcit/webcit.c b/webcit/webcit.c index 8a96a1341..5642ee168 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -6,18 +6,12 @@ * Copyright (c) 1996-2011 by the citadel.org team * * This program is open source software. You can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. + * modify it under the terms of the GNU General Public License, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define SHOW_ME_VAPPEND_PRINTF -- 2.30.2