diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | obj.c | 16 | ||||
-rw-r--r-- | rsyslog.h | 3 |
3 files changed, 18 insertions, 2 deletions
@@ -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 @@ -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; @@ -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) */ |