From 5dd9a6792b4266006cb8b283e6e5996bbd5026a7 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 27 Feb 2008 15:01:53 +0000 Subject: bugfix: object property deserializer did not handle negative numbers --- ChangeLog | 1 + obj.c | 16 +++++++++++++++- rsyslog.h | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc39a39c..2508b4d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,6 +34,7 @@ Version 3.11.6 (rgerhards), 2008-02-?? (see the attached patch) This goes against the logical order of processing, but the legacy options are only few and it doesn't seem to be a problem. +- bugfix: object property deserializer did not handle negative numbers --------------------------------------------------------------------------- Version 3.11.5 (rgerhards), 2008-02-25 - new imgssapi module, changed imtcp module - this enables to load/package diff --git a/obj.c b/obj.c index 5e0fd278..29fc65ec 100644 --- a/obj.c +++ b/obj.c @@ -339,16 +339,27 @@ finalize_it: /* define a helper to make code below a bit cleaner (and quicker to write) */ #define NEXTC CHKiRet(strmReadChar(pStrm, &c))//;dbgprintf("c: %c\n", c); -/* de-serialize an (long) integer */ +/* de-serialize a number */ static rsRetVal objDeserializeNumber(number_t *pNum, strm_t *pStrm) { DEFiRet; number_t i; + int bIsNegative; uchar c; assert(pNum != NULL); NEXTC; + if(c == '-') { + bIsNegative = 1; + NEXTC; + } else { + bIsNegative = 0; + } + + /* we check this so that we get more meaningful error codes */ + if(!isdigit(c)) ABORT_FINALIZE(RS_RET_INVALID_NUMBER); + i = 0; while(isdigit(c)) { i = i * 10 + c - '0'; @@ -357,6 +368,9 @@ static rsRetVal objDeserializeNumber(number_t *pNum, strm_t *pStrm) if(c != ':') ABORT_FINALIZE(RS_RET_INVALID_DELIMITER); + if(bIsNegative) + i *= -1; + *pNum = i; finalize_it: RETiRet; diff --git a/rsyslog.h b/rsyslog.h index 8b4aa354..c44e73cc 100644 --- a/rsyslog.h +++ b/rsyslog.h @@ -133,7 +133,8 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth RS_RET_STACK_EMPTY = -2056, /**< a pop was requested on a stack, but the stack was already empty */ RS_RET_INVALID_VMOP = -2057, /**< invalid virtual machine instruction */ RS_RET_INVALID_VAR = -2058, /**< a var_t or its content is unsuitable, eg. VARTYPE_NONE */ - RS_RET_NOT_A_NUMBER = -2059, /**< e.g. conversion impossible because the string is not a number */ + RS_RET_INVALID_NUMBER = -2059, /**< number invalid during parsing */ + RS_RET_NOT_A_NUMBER = -2060, /**< e.g. conversion impossible because the string is not a number */ /* RainerScript error messages (range 1000.. 1999) */ RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */ -- cgit