diff options
| author | Thorsten Töpper <atsutane@freethoughts.de> | 2025-08-10 20:09:21 +0200 |
|---|---|---|
| committer | Thorsten Töpper <atsutane@freethoughts.de> | 2025-08-10 20:09:21 +0200 |
| commit | 250a82e9c3c55e92fc5d83e78c0fadb9e7ba8b49 (patch) | |
| tree | b617702a37eed0f1c401e20b05126baa060e726c /src | |
| parent | 9e2f3d59cf249403859916df9756c179753ea7e0 (diff) | |
| download | small-utils-250a82e9c3c55e92fc5d83e78c0fadb9e7ba8b49.tar.gz small-utils-250a82e9c3c55e92fc5d83e78c0fadb9e7ba8b49.tar.bz2 | |
split_for_sort: switch from strncpy to memcpy
Diffstat (limited to 'src')
| -rw-r--r-- | src/split_for_sort.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/split_for_sort.c b/src/split_for_sort.c index 8f5d8b8..e57c2b3 100644 --- a/src/split_for_sort.c +++ b/src/split_for_sort.c @@ -104,7 +104,7 @@ inline size_t list_check_length(struct list_head *list) { } inline int push_into_list_unique(struct list_head *list, char *name) { - size_t name_length = 0; /* required for __builtin___strncpy_chk */ + size_t name_length = 0; struct list_node *ptr = NULL, *tmp = NULL; if (list == NULL || name == NULL || name[0] == '\0') { LOGERR("ERROR: Invalid function arguments.\n"); @@ -124,12 +124,12 @@ inline int push_into_list_unique(struct list_head *list, char *name) { } name_length = strlen(name); - if ((tmp->name = calloc(name_length+2, sizeof(char))) == NULL) { - LOGERR("ERROR Failed to allocate %lu bytes for data in list\n", strlen(name)+2); + if ((tmp->name = calloc(name_length+1, sizeof(char))) == NULL) { + LOGERR("ERROR Failed to allocate %lu bytes for data in list\n", strlen(name)+1); free(tmp); return -3; } - strncpy(tmp->name, name, name_length+1); + memcpy(tmp->name, name, name_length); tmp->fd = NULL; tmp->next = list->first; list->first = tmp; |
