From nobody Sat Feb 7 20:39:38 2026 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22CE77494 for ; Sat, 17 Jan 2026 13:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768657819; cv=none; b=Gzw5tlFs3tGPElROYMDVbiPCdB8XkF5I8eOqVx7voepS9nBAfkxdP3aH559BwHRyzgTiQfxFuwtyDaeLv6sWbRKe8mVuE7Cygdx1Z+SJtbEhR9ByrKqWqc544Zz2zFI0nlsSyRLgOuqWMtm6PGdJtPqq3QJiv7LqvBwRZ6HMdUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768657819; c=relaxed/simple; bh=f2FzNrQRPuOBpmz0K6CPi61aEg6mvyxObbZQdyOtzEM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sKJqVyXVP4e1hSUrQMsWkG7yMXyJGqX4GGkSe/k2klG7VpH1geyzumVcE58RURTcbYtkNf4d7zxFaJft86UPRWLW9yVCrXbfn4XwQ9jhXOtnH30e4e6py/s1RqLHLKYBFYRz3nRnEeVBqm1xF41Or93iL4+I2UBbGfLmSvpSsxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=psZXuwcE; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="psZXuwcE" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768657816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CdSGKPi0UzYPy1A/sAMwazTYJ4LVr/kx3bz0fsVQIGM=; b=psZXuwcEUNDg7O89Q992cphH9z7nSsANCnPzMH8ScbAtgWeL6YEfA7Nr4EQq24F1ijkzeg FxEn+jCOQi8jYMPTre0PhzvNqh75kHde/zMw7mYR4OpDWoNh7cY1Zx13cHLr2FYInDVmGG joh6bAdS3LkIOGbGtmWRW0IPSqyxOVM= From: Thorsten Blum To: Mike Marshall , Martin Brandenburg Cc: Thorsten Blum , devel@lists.orangefs.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/orangefs: Replace deprecated strcpy with memcpy + strscpy Date: Sat, 17 Jan 2026 14:49:53 +0100 Message-ID: <20260117134953.882249-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" strcpy() is deprecated [1] and using strcat() is discouraged. In orangefs_debugfs_init() and orangefs_client_debug_init(), replace them with memcpy() since the string lengths are already known. Replace all other uses of strcpy() with the safer strscpy(). Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy= [1] Signed-off-by: Thorsten Blum --- fs/orangefs/orangefs-debugfs.c | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c index 79267b3419f2..002092950605 100644 --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -238,14 +238,16 @@ void orangefs_debugfs_init(int debug_mask) static void orangefs_kernel_debug_init(void) { static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] =3D { }; + size_t len =3D strlen(kernel_debug_string); =20 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); =20 - if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { - strcpy(k_buffer, kernel_debug_string); - strcat(k_buffer, "\n"); + if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { + memcpy(k_buffer, kernel_debug_string, len); + k_buffer[len] =3D '\n'; + k_buffer[len + 1] =3D '\0'; } else { - strcpy(k_buffer, "none\n"); + strscpy(k_buffer, "none\n"); pr_info("%s: overflow 1!\n", __func__); } =20 @@ -336,16 +338,17 @@ static int help_show(struct seq_file *m, void *v) */ static void orangefs_client_debug_init(void) { - static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] =3D { }; + size_t len =3D strlen(client_debug_string); =20 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); =20 - if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { - strcpy(c_buffer, client_debug_string); - strcat(c_buffer, "\n"); + if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { + memcpy(c_buffer, client_debug_string, len); + c_buffer[len] =3D '\n'; + c_buffer[len + 1] =3D '\0'; } else { - strcpy(c_buffer, "none\n"); + strscpy(c_buffer, "none\n"); pr_info("%s: overflow! 2\n", __func__); } =20 @@ -748,15 +751,14 @@ static void debug_mask_to_string(void *mask, int type) else if (len) kernel_debug_string[len - 1] =3D '\0'; else if (type) - strcpy(client_debug_string, "none"); + strscpy(client_debug_string, "none"); else - strcpy(kernel_debug_string, "none"); + strscpy(kernel_debug_string, "none"); =20 out: gossip_debug(GOSSIP_UTILS_DEBUG, "%s: string:%s:\n", __func__, debug_strin= g); =20 return; - } =20 static void do_k_string(void *k_mask, int index) @@ -775,7 +777,7 @@ static void do_k_string(void *k_mask, int index) strcat(kernel_debug_string, ","); } else { gossip_err("%s: overflow!\n", __func__); - strcpy(kernel_debug_string, ORANGEFS_ALL); + strscpy(kernel_debug_string, ORANGEFS_ALL); goto out; } } @@ -802,7 +804,7 @@ static void do_c_string(void *c_mask, int index) strcat(client_debug_string, ","); } else { gossip_err("%s: overflow!\n", __func__); - strcpy(client_debug_string, ORANGEFS_ALL); + strscpy(client_debug_string, ORANGEFS_ALL); goto out; } } @@ -838,14 +840,14 @@ static int check_amalgam_keyword(void *mask, int type) =20 if ((c_mask->mask1 =3D=3D cdm_array[client_all_index].mask1) && (c_mask->mask2 =3D=3D cdm_array[client_all_index].mask2)) { - strcpy(client_debug_string, ORANGEFS_ALL); + strscpy(client_debug_string, ORANGEFS_ALL); rc =3D 1; goto out; } =20 if ((c_mask->mask1 =3D=3D cdm_array[client_verbose_index].mask1) && (c_mask->mask2 =3D=3D cdm_array[client_verbose_index].mask2)) { - strcpy(client_debug_string, ORANGEFS_VERBOSE); + strscpy(client_debug_string, ORANGEFS_VERBOSE); rc =3D 1; goto out; } @@ -854,7 +856,7 @@ static int check_amalgam_keyword(void *mask, int type) k_mask =3D (__u64 *) mask; =20 if (*k_mask >=3D s_kmod_keyword_mask_map[k_all_index].mask_val) { - strcpy(kernel_debug_string, ORANGEFS_ALL); + strscpy(kernel_debug_string, ORANGEFS_ALL); rc =3D 1; goto out; } --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4