From patchwork Tue Jul 25 22:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13327165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B91FEB64DD for ; Tue, 25 Jul 2023 22:10:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D1A327F4; Wed, 26 Jul 2023 00:09:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D1A327F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1690323011; bh=PhUj2cXtcqtjhYpon1W91iiAfF7M/UqU4Wb0CfeBYMk=; h=Date:Subject:From:To:Cc:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=pGN4PmKZVcPvv5j020XBWk+6pRbSI3XrKXk1d4kBAv/1qeCzuDqOxw+TPAQkSQaA1 0XavJFCvToTCwwB6HaBCz6CzbkNvdcKqwJijye6Mk0ogMk1V20qcmtO42L6ehevOvO Kd9XMOpHjiwdhCbHRwvOF9nVjqlri9a0NLlB6p/w= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 80BD6F800C7; Wed, 26 Jul 2023 00:08:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 32F5AF8019B; Wed, 26 Jul 2023 00:08:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 94B3CF8019B; Wed, 26 Jul 2023 00:08:49 +0200 (CEST) Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9317DF800C7 for ; Wed, 26 Jul 2023 00:08:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9317DF800C7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=x1EURPB8 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d052f49702dso5441726276.3 for ; Tue, 25 Jul 2023 15:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690322920; x=1690927720; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=1NWycEa65d4tlLHM/aUQNHUmkrnQ5gy649oFMAUFu0Y=; b=x1EURPB8q2FI+3WTNRHFSD+/QMHRtAIewp3VseLuRl7bX8IOlOLFy3quhxBmmtntOG GA/g/RATylp6grK6gJ9mdWtfWy83FF+b97IUhdd7Gsd7KIXxhNuB9Z09oKClQijqS947 fM5jMnFPC7L7DAeSZw28wP3wNCGp1VbZh1LMrqSwITOV6UzlaECYWCQzaQc4IeqJr5Ic DKJ3bYk/ET4D5thfnNEkr0DotUos69dxbSjM1PAtmORcALtzBfBUSI1Cb2LuOhLmntDU vTECUN+t07IC0aNbgcw+5LSU4N0Tj8FMJtsPDYk6u3f/MwhUcRkIMDQGHorJGBYgDm9K V1Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322920; x=1690927720; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1NWycEa65d4tlLHM/aUQNHUmkrnQ5gy649oFMAUFu0Y=; b=WTeAWHLbc6ZpcaIAbOeu4+Rgp1lDHHhX3CVHhA91xh97fGG8UQWGU1TAVCvrUMSktE JTrf4PEVxgWQ3rGNMS+sX+kJ2wJspJu9gwxPnFB5hefBkhDWrvt3noGwW05duZsrE6MJ dcTqGR1QmQnanaxX6wB+UsxFfbIiJiw9+NehahbUEfZ+lxrW5QcNj9liJDVDw5NHCZ2e +a6k5pHoLV5hyUTiVwa5vfEJfO7NNICs+maah9zAcV7NaHVQ8ZelOwS9yCEjw9rtYgH5 iGpJuqSYq0yeYP8fJi3Hx1N+aesSAEy74eTUVPG7t/KIF/c8eE5h2QvB1qVSGPnPt/9q NAmQ== X-Gm-Message-State: ABy/qLbIOU7WArMaozZk1P+bvhPIVsCpCzutkh0pKyvqRQBma6Eghy63 3k+Kdv45NYFObwWDFJ5hV1KXfaZNjCCuXI7CnA== X-Google-Smtp-Source: APBJJlENtGndeMK75xsqbP+rObTFZUl8GefO08l5IcCtgMR26J0r2rSOjJAMnNmTOUoRnsSrpVgw4Y3QHRWFE05m4w== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:69c8:0:b0:d0c:e37:b749 with SMTP id e191-20020a2569c8000000b00d0c0e37b749mr1345ybc.10.1690322919734; Tue, 25 Jul 2023 15:08:39 -0700 (PDT) Date: Tue, 25 Jul 2023 22:08:38 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAOVHwGQC/x2NwQrCMBBEf6Xs2YUmGhR/RTzEzVYXNCmbGCyl/ 97Fy8BjHjMrVFbhCtdhBeUuVUo2cIcB6BXzk1GSMfjRH8ezD1jLNydLQsmN3xh7ReVP6YyJZ2W Kja1vmmle0D/o5GKIYbo4sE0TJvn9/273bdsB0LrmxH8AAAA= X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1690322918; l=1683; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=PhUj2cXtcqtjhYpon1W91iiAfF7M/UqU4Wb0CfeBYMk=; b=hwCrKKl4MBwnYeKbpJ7VXwZ58MxHlq/hUWRmyIcm4i/2grmqWc8hNmK+AMZ6GxlAJ+aUw6C6Z JLfTXt31O93DIg9K4aTcdVaMMNARadNBYo+WiR96LLszjj0XJbcnpNH X-Mailer: b4 0.12.3 Message-ID: <20230725-sound-soc-intel-avs-remove-deprecated-strncpy-v1-1-6357a1f8e9cf@google.com> Subject: [PATCH] ASoC: intel: avs: refactor strncpy usage in topology From: justinstitt@google.com To: Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Kees Cook , Nathan Chancellor , Justin Stitt Message-ID-Hash: RSZRAIZJWEQIC2YQBY3WCMEK2FJIR62U X-Message-ID-Hash: RSZRAIZJWEQIC2YQBY3WCMEK2FJIR62U X-MailFrom: 350fAZAsKCqQNYWXMRWXMXXKSSKPI.GSQEPWE-HIZIPEPWE-TVSNIGX.SVK@flex--justinstitt.bounces.google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: `strncpy` is deprecated for use on NUL-terminated destination strings [1]. A suitable replacement is `strscpy` [2]. There are some hopes that someday the `strncpy` api could be ripped out due to the vast number of suitable replacements (strscpy, strscpy_pad, strtomem, strtomem_pad, strlcpy) [1]. [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [2]: manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html Reviewed-by: Kees Cook Reviewed-by: Amadeusz Sławiński --- Link: https://github.com/KSPP/linux/issues/90 Signed-off-by: Justin Stitt --- sound/soc/intel/avs/topology.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- base-commit: 0b4a9fdc9317440a71d4d4c264a5650bf4a90f3c change-id: 20230725-sound-soc-intel-avs-remove-deprecated-strncpy-2bc41a5a5f81 Best regards, diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c index cdb4ec500261..45d0eb2a8e71 100644 --- a/sound/soc/intel/avs/topology.c +++ b/sound/soc/intel/avs/topology.c @@ -1388,12 +1388,12 @@ static int avs_route_load(struct snd_soc_component *comp, int index, port = __ffs(mach->mach_params.i2s_link_mask); snprintf(buf, len, route->source, port); - strncpy((char *)route->source, buf, len); + strscpy((char *)route->source, buf, len); snprintf(buf, len, route->sink, port); - strncpy((char *)route->sink, buf, len); + strscpy((char *)route->sink, buf, len); if (route->control) { snprintf(buf, len, route->control, port); - strncpy((char *)route->control, buf, len); + strscpy((char *)route->control, buf, len); } }