]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
mini-os: fix nodename generation in init_netfront
authorMatthew Daley <mattjd@gmail.com>
Wed, 18 Sep 2013 03:37:57 +0000 (15:37 +1200)
committerIan Campbell <ian.campbell@citrix.com>
Sat, 21 Sep 2013 15:41:42 +0000 (16:41 +0100)
Using strlen here makes no sense.

Coverity-ID: 1056053
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
netfront.c

index 4e087a56ed86ea5157bbf35d067826ca447d3b55..a9999855758c7885c6f69e1335ea356fcb5c4665 100644 (file)
@@ -309,8 +309,10 @@ struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(unsigned
 
     if (!_nodename)
         snprintf(nodename, sizeof(nodename), "device/vif/%d", netfrontends);
-    else
-        strncpy(nodename, _nodename, strlen(nodename));
+    else {
+        strncpy(nodename, _nodename, sizeof(nodename) - 1);
+        nodename[sizeof(nodename) - 1] = 0;
+    }
     netfrontends++;
 
     if (!thenetif_rx)