aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2021-03-01 08:45:17 +0100
committerDamjan Marion <dmarion@me.com>2021-03-04 09:09:08 +0000
commit57084e54082a29d19d2e4b71581c2a4980f8ce15 (patch)
tree11c937ad36d0da11ef4407fc6384feed0d105a09 /extras/libmemif
parent0ac5782e600097b66e6b06e0b9edc79651f3a4bd (diff)
libmemif: socket filename length 108
Dynamic size array was causing trouble in strlcpy. LINUX allows for max 108 filename length, so we can use that to make the array constant size. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I76b1fc41f9d93cfbc9ad11bdca0c96a1fc261e84
Diffstat (limited to 'extras/libmemif')
-rw-r--r--extras/libmemif/src/main.c28
-rw-r--r--extras/libmemif/src/memif_private.h2
2 files changed, 3 insertions, 27 deletions
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c
index 1eb6929137e..36f1251a158 100644
--- a/extras/libmemif/src/main.c
+++ b/extras/libmemif/src/main.c
@@ -948,13 +948,7 @@ memif_create_socket (memif_socket_handle_t * sock, const char *filename,
}
memset (ms, 0, sizeof (memif_socket_t));
/* set filename */
- ms->filename = lm->alloc (strlen (filename) + sizeof (char));
- if (ms->filename == NULL)
- {
- err = MEMIF_ERR_NOMEM;
- goto error;
- }
- memset (ms->filename, 0, strlen (filename) + sizeof (char));
+ memset (ms->filename, 0, sizeof (ms->filename));
strlcpy ((char *) ms->filename, filename, sizeof (ms->filename));
ms->type = MEMIF_SOCKET_TYPE_NONE;
@@ -977,11 +971,6 @@ memif_create_socket (memif_socket_handle_t * sock, const char *filename,
error:
if (ms != NULL)
{
- if (ms->filename != NULL)
- {
- lm->free (ms->filename);
- ms->filename = NULL;
- }
if (ms->fd > 0)
{
close (ms->fd);
@@ -1032,13 +1021,7 @@ memif_per_thread_create_socket (memif_per_thread_main_handle_t pt_main,
memset (ms, 0, sizeof (memif_socket_t));
ms->lm = lm;
/* set filename */
- ms->filename = lm->alloc (strlen (filename) + sizeof (char));
- if (ms->filename == NULL)
- {
- err = MEMIF_ERR_NOMEM;
- goto error;
- }
- memset (ms->filename, 0, strlen (filename) + sizeof (char));
+ memset (ms->filename, 0, sizeof (ms->filename));
strlcpy ((char *) ms->filename, filename, sizeof (ms->filename));
ms->type = MEMIF_SOCKET_TYPE_NONE;
@@ -1061,11 +1044,6 @@ memif_per_thread_create_socket (memif_per_thread_main_handle_t pt_main,
error:
if (ms != NULL)
{
- if (ms->filename != NULL)
- {
- lm->free (ms->filename);
- ms->filename = NULL;
- }
if (ms->fd > 0)
{
close (ms->fd);
@@ -1796,8 +1774,6 @@ memif_delete_socket (memif_socket_handle_t * sock)
lm->free (ms->interface_list);
ms->interface_list = NULL;
- lm->free (ms->filename);
- ms->filename = NULL;
lm->free (ms);
*sock = ms = NULL;
diff --git a/extras/libmemif/src/memif_private.h b/extras/libmemif/src/memif_private.h
index 59899fd6285..9542936983e 100644
--- a/extras/libmemif/src/memif_private.h
+++ b/extras/libmemif/src/memif_private.h
@@ -193,7 +193,7 @@ typedef struct
int fd;
uint16_t use_count;
memif_socket_type_t type;
- uint8_t *filename;
+ uint8_t filename[108];
/* unique database */
struct libmemif_main *lm;
uint16_t interface_list_len;