]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
log: Check message buffer length to avoid overflow 897/head
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Tue, 3 Feb 2015 11:10:52 +0000 (12:10 +0100)
committerNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Tue, 3 Feb 2015 11:10:52 +0000 (12:10 +0100)
Check that adding strlcpy result to the message length didn't exceed
size of the message buffer to avoid underflow in calculating remaining
size and overflowing the buffer.

src/main/log.c

index 7470897df68b45bcb000d406005eb5f329b01666..16d3fafd7fa4b49624fa45459db6907182c4ce27 100644 (file)
@@ -311,6 +311,8 @@ void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ..
 
                if (len < sizeof(buffer)) {
                        len += strlcpy(buffer + len, fr_int2str(levels, (lvl & ~L_CONS), ": "), sizeof(buffer) - len);
+                       if (len >= sizeof(buffer))
+                               len = sizeof(buffer) - 1;
                }
        }