From: Willy Tarreau Date: Thu, 24 Jan 2013 00:18:16 +0000 (+0100) Subject: BUG/MINOR: log: improper NULL return check on utoa_pad() X-Git-Tag: v1.5-dev18~117 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e60cd84b7fef86bacf93212e329453d35549b01;p=thirdparty%2Fhaproxy.git BUG/MINOR: log: improper NULL return check on utoa_pad() utoa_pad() is directly fed into tmplog, which is checked for NULL. First, when NULLs are possible, they should be put into a temp variable in order to preserve tmplog, and second, this return value can never be NULL because the value passed is tv_usec/1000 (between "0" and "999") with a 4-char output. However better fix the check in case this code gets improperly copy-pasted for another usage later. Reported-by: Dinko Korunic --- diff --git a/src/log.c b/src/log.c index 9e909e299c..d36d879881 100644 --- a/src/log.c +++ b/src/log.c @@ -1055,10 +1055,11 @@ int build_logline(struct session *s, char *dst, size_t maxsize, struct list *lis } else { if ((dst + maxsize - tmplog) < 4) goto out; - tmplog = utoa_pad((unsigned int)s->logs.accept_date.tv_usec/1000, - tmplog, 4); - if (!tmplog) + ret = utoa_pad((unsigned int)s->logs.accept_date.tv_usec/1000, + tmplog, 4); + if (ret == NULL) goto out; + tmplog = ret; last_isspace = 0; } break;