From: S.Çağlar Onur Date: Thu, 28 Jan 2010 16:26:35 +0000 (+0000) Subject: fix mac address are truncated problem when compiling ulogd with -D_FORTIFY_SOURCE... X-Git-Tag: DistributedRateLimiting-0.1-0~8 X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=commitdiff_plain;h=bf4fd3eaef0d8334db1412ea6e25f4dd3c900a59 fix mac address are truncated problem when compiling ulogd with -D_FORTIFY_SOURCE=2, https://bugzilla.redhat.com/show_bug.cgi?id=247345 --- diff --git a/extensions/ulogd_BASE.c b/extensions/ulogd_BASE.c index 646f55f..42e23f4 100644 --- a/extensions/ulogd_BASE.c +++ b/extensions/ulogd_BASE.c @@ -65,7 +65,7 @@ static ulog_iret_t *_interp_raw(ulog_interpreter_t *ip, { unsigned char *p; int i; - char *buf, *oldbuf = NULL; + char *buf = NULL; ulog_iret_t *ret = ip->result; if (pkt->mac_len) { @@ -77,9 +77,8 @@ static ulog_iret_t *_interp_raw(ulog_interpreter_t *ip, *buf = '\0'; p = pkt->mac; - oldbuf = buf; for (i = 0; i < pkt->mac_len; i++, p++) - sprintf(buf, "%s%02x%c", oldbuf, *p, i==pkt->mac_len-1 ? ' ':':'); + sprintf(buf + (i*3), "%02x%c", *p, i==pkt->mac_len-1 ? ' ':':'); ret[0].value.ptr = buf; ret[0].flags |= ULOGD_RETF_VALID; }