diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-27 15:01:53 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-27 15:01:53 +0000 |
commit | 5dd9a6792b4266006cb8b283e6e5996bbd5026a7 (patch) | |
tree | 0e52a5bcffc9c49467755381ad84a6c2c6627ade /obj.c | |
parent | 58bb094fbaf6fac3ccd4db802db1cfcb37f3d01c (diff) | |
download | rsyslog-5dd9a6792b4266006cb8b283e6e5996bbd5026a7.tar.gz rsyslog-5dd9a6792b4266006cb8b283e6e5996bbd5026a7.tar.xz rsyslog-5dd9a6792b4266006cb8b283e6e5996bbd5026a7.zip |
bugfix: object property deserializer did not handle negative numbers
Diffstat (limited to 'obj.c')
-rw-r--r-- | obj.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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; |