net/ark: fix buffer not null terminated
authorJohn Miller <john.miller@atomicrules.com>
Tue, 16 May 2017 16:14:15 +0000 (12:14 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:25 +0000 (10:41 +0100)
Coverity issue: 144512
Coverity issue: 144513
Fixes: 9c7188a68d7b ("net/ark: provide API for hardware modules pktchkr and pktgen")
Cc: stable@dpdk.org
Signed-off-by: John Miller <john.miller@atomicrules.com>
drivers/net/ark/ark_pktchkr.c
drivers/net/ark/ark_pktgen.c

index 62b3673..c3040af 100644 (file)
@@ -372,7 +372,7 @@ set_arg(char *arg, char *val)
                        o->v.INT = atoll(val);
                        break;
                case OTSTRING:
-                       strncpy(o->v.STR, val, ARK_MAX_STR_LEN);
+                       snprintf(o->v.STR, ARK_MAX_STR_LEN, "%s", val);
                        break;
                }
                return 1;
index bdac054..8c7a8a2 100644 (file)
@@ -354,7 +354,7 @@ pmd_set_arg(char *arg, char *val)
                        o->v.INT = atoll(val);
                        break;
                case OTSTRING:
-                       strncpy(o->v.STR, val, ARK_MAX_STR_LEN);
+                       snprintf(o->v.STR, ARK_MAX_STR_LEN, "%s", val);
                        break;
                }
                return 1;