]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Fix possible array overrun
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 2 Feb 2017 00:51:31 +0000 (19:51 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 2 Feb 2017 00:51:31 +0000 (19:51 -0500)
It is possible if the hostname is > 32
characters that we would just overrun the
client_name data structure.  Truncate
the hostname string to 31 characters (to allow for NULL)

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/ptm_lib.c

index 0666797fadad8f993118de3ac0eaddf26662133b..a93d7b84767da16d3367c82c26cc6b94f61a0000 100644 (file)
@@ -458,7 +458,7 @@ ptm_lib_register(char *client_name,
     hdl = calloc(1, sizeof(*hdl));
 
     if (hdl) {
-        strcpy(hdl->client_name, client_name);
+        strncpy(hdl->client_name, client_name, PTMLIB_MAXNAMELEN - 1);
         hdl->cmd_cb = cmd_cb;
         hdl->notify_cb = notify_cb;
         hdl->response_cb = response_cb;