fix mac address are truncated problem when compiling ulogd with -D_FORTIFY_SOURCE...
S.Çağlar Onur [Thu, 28 Jan 2010 16:26:35 +0000 (16:26 +0000)]
extensions/ulogd_BASE.c

index 646f55f..42e23f4 100644 (file)
@@ -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;
        }