From db40a2e33c5cb7c58548310a70b9b91f8cac1298 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 4 May 2024 22:00:51 +0200 Subject: [PATCH] cov: replace strcat with safe snprintf --- lib/misc/lvm-flock.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/misc/lvm-flock.c b/lib/misc/lvm-flock.c index 4ba85e0fb..1b6d5f3eb 100644 --- a/lib/misc/lvm-flock.c +++ b/lib/misc/lvm-flock.c @@ -159,10 +159,9 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock static int _do_write_priority_flock(const char *file, int *fd, int operation, uint32_t nonblock) { int r, fd_aux = -1; - char *file_aux = alloca(strlen(file) + sizeof(AUX_LOCK_SUFFIX)); + char file_aux[PATH_MAX]; - strcpy(file_aux, file); - strcat(file_aux, AUX_LOCK_SUFFIX); + snprintf(file_aux, sizeof(file_aux), "%s%s", file, AUX_LOCK_SUFFIX); if ((r = _do_flock(file_aux, &fd_aux, LOCK_EX, nonblock))) { if (operation == LOCK_EX) { -- 2.43.5