mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
cursor/os-compatibility: remove strcpy/strcat usage
These functions don't perform bounds checking, so they are easy to misuse and complicate audits. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
355c8e885c
commit
0297c2c47a
1 changed files with 5 additions and 3 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_MEMFD_CREATE
|
||||
|
|
@ -118,6 +119,7 @@ os_create_anonymous_file(off_t size)
|
|||
static const char template[] = "/wayland-cursor-shared-XXXXXX";
|
||||
const char *path;
|
||||
char *name;
|
||||
size_t name_size;
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_MEMFD_CREATE
|
||||
|
|
@ -139,12 +141,12 @@ os_create_anonymous_file(off_t size)
|
|||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue