These functions don't perform bounds checking, so they are easy to
misuse and complicate audits.
Signed-off-by: Simon Ser <contact@emersion.fr>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_MEMFD_CREATE
static const char template[] = "/wayland-cursor-shared-XXXXXX";
const char *path;
char *name;
+ size_t name_size;
int fd;
#ifdef HAVE_MEMFD_CREATE
return -1;
}
- name = malloc(strlen(path) + sizeof(template));
+ name_size = strlen(path) + sizeof(template);
+ name = malloc(name_size);
if (!name)
return -1;
- strcpy(name, path);
- strcat(name, template);
+ snprintf(name, name_size, "%s%s", path, template);
fd = create_tmpfile_cloexec(name);