summaryrefslogtreecommitdiffstats
path: root/obj.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-27 15:01:53 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-27 15:01:53 +0000
commit5dd9a6792b4266006cb8b283e6e5996bbd5026a7 (patch)
tree0e52a5bcffc9c49467755381ad84a6c2c6627ade /obj.c
parent58bb094fbaf6fac3ccd4db802db1cfcb37f3d01c (diff)
downloadrsyslog-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.c16
1 files changed, 15 insertions, 1 deletions
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;