dyn_gw: fix a Coverity warning
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 25 Feb 2015 20:16:11 +0000 (21:16 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 25 Feb 2015 20:47:56 +0000 (21:47 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/dyn_gw/src/olsrd_dyn_gw.c

index d5883d9..e098bbe 100644 (file)
@@ -214,7 +214,8 @@ set_plugin_cmd(const char *value, void *data __attribute__ ((unused)), set_plugi
   size_t len = strlen(value);
 
   if (len < PING_CMD_MAX_LEN) {
-    strncpy(ping_cmd, value, sizeof(ping_cmd));
+    strncpy(ping_cmd, value, MAX(sizeof(ping_cmd), PING_CMD_MAX_LEN - 1));
+    ping_cmd[PING_CMD_MAX_LEN - 1] = '\0';
     return 0;
   }