From 02d86f31f65a9964682e9e4ef2ac699cb0307702 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 13 Dec 2008 14:04:51 +0000 Subject: [PATCH] * don't ignore the last char of a template * don't access aray indexes before chcking them. --- webcit/subst.c | 14 +++++++------- webcit/webserver.c | 10 ++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/webcit/subst.c b/webcit/subst.c index 716a46e71..41aad9274 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -936,21 +936,21 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf, case SV_CUST_STR_CONDITIONAL: case SV_CONDITIONAL: case SV_NEG_CONDITIONAL: - if (NewToken->Params[1]->lvalue == 0) { + if (NewToken->nParameters <2) { lprintf(1, "Conditional (in '%s' line %ld); " - "Conditional ID mustn't be 0! [%s]\n", + "require at least 2 parameters, you gave %ld params [%s]\n", ChrPtr(pTmpl->FileName), NewToken->Line, + NewToken->nParameters, ChrPtr(NewToken->FlatToken)); NewToken->Flags = 0; break; } - if (NewToken->nParameters <2) { + if (NewToken->Params[1]->lvalue == 0) { lprintf(1, "Conditional (in '%s' line %ld); " - "require at least 2 parameters, you gave %ld params [%s]\n", + "Conditional ID mustn't be 0! [%s]\n", ChrPtr(pTmpl->FileName), NewToken->Line, - NewToken->nParameters, ChrPtr(NewToken->FlatToken)); NewToken->Flags = 0; break; @@ -1070,7 +1070,7 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) pts = pch; /** Found one? parse it. */ - for (; pch < pE - 1; pch ++) { + for (; pch <= pE - 1; pch ++) { if (*pch == '"') InDoubleQuotes = ! InDoubleQuotes; else if (*pch == '\'') @@ -1081,7 +1081,7 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) break; } } - if (pch + 1 >= pE) + if (pch + 1 > pE) continue; pte = pch; PutNewToken(NewTemplate, diff --git a/webcit/webserver.c b/webcit/webserver.c index 5c107f382..480cdcf0d 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -699,6 +699,16 @@ int main(int argc, char **argv) SortHash = NewHash(1, NULL); LoadZoneFiles(); + StrBuf *foo=NewStrBufPlain("", -1); + StrBuf *bar = NewStrBufPlain("A", -1); + + StrBufExtract_token(bar, foo, 0, '|'); + StrBufExtract_token(bar, foo, 1, '|'); + StrBufExtract_token(bar, foo, 2, '|'); + StrBufExtract_token(bar, foo, 3, '|'); + StrBufExtract_token(bar, foo, 4, '|'); + StrBufExtract_token(bar, foo, 5, '|'); + StrBufExtract_token(bar, foo, 6, '|'); #ifdef DBG_PRINNT_HOOKS_AT_START dbg_PrintHash(HandlerHash, nix, NULL); -- 2.39.2