26.10.2013 17:56, Rainer Gerhards:
On Sat, Oct 26, 2013 at 1:10 AM, Pavel Levshin <[email protected]> wrote:

This is due to a bug in libestr, see patch.


Thanks, also merged now. Will be released as 0.1.9 on Monday.


Have you missed second version of the patch, which adds proper handling of negative numbers?

It will still fail to display -LLONG_MAX, btw.


--
Pavel Levshin

>From 879f94af72a6dcb632f3e87904d0cf9494b0ab04 Mon Sep 17 00:00:00 2001
From: Pavel Levshin <[email protected]>
Date: Sat, 26 Oct 2013 12:33:12 +0400
Subject: [PATCH] Bugfixes to StrFromNumber

---
 src/string.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/string.c b/src/string.c
index 3dccd71..483546d 100644
--- a/src/string.c
+++ b/src/string.c
@@ -151,8 +151,14 @@ es_newStrFromNumber(long long num)
 {
        char numbuf[20];        /* 2^64 has 20 digits ;) */
        int i,j;
+       char minus = '\0';
        es_str_t *s;
        
+       if (num < 0) {
+           minus = '-';
+           num = -num;
+       }
+       
        /* generate string (reversed) */
        for(i = 0 ; num != 0 ; ++i) {
                numbuf[i] = num % 10 + '0';
@@ -160,11 +166,13 @@ es_newStrFromNumber(long long num)
        }
        if(i == 0)
                numbuf [i++] = '0';
+       if (minus != '\0')
+               numbuf[i++] = minus;
 
        /* now create the actual string */
        if((s = es_newStr(i)) == NULL) goto done;
        s->lenStr = i;
-       for(j = 0 ; --i >= 0 ; ++j, --i) {
+       for(j = 0 ; --i >= 0 ; ++j) {
                es_getBufAddr(s)[j] = numbuf[i];
        }
 
-- 
1.7.9.5

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to