Fix potential core dump when closing ports at exit
[samplevnf.git] / VNFs / DPPD-PROX / prox_shared.c
index 890d564..52f4eb1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-// Copyright (c) 2010-2017 Intel Corporation
+// Copyright (c) 2010-2020 Intel Corporation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 #include "log.h"
 #include "prox_shared.h"
 #include "prox_globals.h"
+#include "prox_compat.h"
 
 #define INIT_HASH_TABLE_SIZE 8192
 
@@ -58,9 +59,9 @@ static void prox_sh_create_hash(struct prox_shared *ps, size_t size)
        PROX_PANIC(ps->hash == NULL, "Failed to create hash table for shared data");
        ps->size = size;
        if (ps->size == INIT_HASH_TABLE_SIZE)
-               plog_info("Shared data tracking hash table created with size %zu\n", ps->size);
+               plog_info("\tShared data tracking hash table created with size %zu\n", ps->size);
        else
-               plog_info("Shared data tracking hash table grew to %zu\n", ps->size);
+               plog_info("\tShared data tracking hash table grew to %zu\n", ps->size);
 }
 
 #if RTE_VERSION >= RTE_VERSION_NUM(2,1,0,0)
@@ -84,7 +85,7 @@ static int prox_sh_add(struct prox_shared *ps, const char *name, void *data)
        char key[256] = {0};
        int ret;
 
-       strncpy(key, name, sizeof(key));
+       prox_strncpy(key, name, sizeof(key));
        if (ps->size == 0) {
                prox_sh_create_hash(ps, INIT_HASH_TABLE_SIZE);
        }
@@ -121,7 +122,7 @@ static void *prox_sh_find(struct prox_shared *sh, const char *name)
        if (!sh->hash)
                return NULL;
 
-       strncpy(key, name, sizeof(key));
+       prox_strncpy(key, name, sizeof(key));
        ret = rte_hash_lookup_data(sh->hash, key, &data);
        if (ret >= 0)
                return data;