From nobody Thu Feb 13 17:51:29 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yv2md3P7Xz5n3ZL; Thu, 13 Feb 2025 17:51:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yv2md2y43z3vrC; Thu, 13 Feb 2025 17:51:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739469089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Vei3qUMMLtTGkXAFVabP9kbczUi1vQF1vCoChb8eBc=; b=lkf4u9E8iL9W7UQDyrQgg2p1/4zJypm7uifKapkcsGfI3137sYiEruzXOJ5xnC5ex+HHzp kFzMqwt+ZLbn2Q9Unslvjn8SiE6PBX5PUW6hYN8+sDBTdR2yrU+iltaWIPszpP4iXZ6Fxa xqVM7fStG3RK4g5U7gCEZkWIipgzEVaDzL1q4o+V/1EdOADKSA6k3lW7F6QtyVMpAGMGa7 UDbc7kchvKVGGOce9VB8kVr36DdBbGn17YvRy76aN8eJXTDUT1pvywJFjflRRxZokPgSEU OslFnFldkzjq/ORWjO3wbylaxI2ZbwfX9X/BEo/lwrgGiUI9SZ2DnUT6nJXRTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739469089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Vei3qUMMLtTGkXAFVabP9kbczUi1vQF1vCoChb8eBc=; b=e8kCe3Hq7MwgsSlWdBOpiZAtnI7M5KeVia7EIHtJufJ5uaDF3v06CgTgYDCwm6rTInW4Jd S15ATEMHY9wdPR5uEfjRh4oJUTcSRHvkVfuMbL8hMKAujLcUcfk277RQ9Rd+ROBJHyMqVf CTPkjmouPBMCpIMZGXDgji2siaXyiH6ABR8beN83VWwqc5ga5HaVl0y96IHBuy66Zrp6iQ 0iKYBJlGWo+khtsM3AB/dwzkKcMcr8nuyrOvuvhj5KTj1uCU3FwP6gB0+hY3/05PAk8l3h 9q9XPydY+WiwKBo9bNcySpUW1lmU/HNO/VPT9NnvH9Q0cO1QoIB13sXTRspb0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1739469089; a=rsa-sha256; cv=none; b=GTKgFfMJ2P7VpKCvfLufLtb7JKgdyNzbFL4vFRrfO/W6nN3Y4C6u+7s5evfENGg6bVwmDn E1uSt6SCfPD5NAuaVNDmtnNa/okikaCTZ9D8/+oIH805mwESn+N0hWDSOx6ClziiORuCW7 yQEFPH+76XMemILV1CS+neCOFgQXhIPv3xvrMH0vAj7S3UlQamwMwWZM6J20/Cqz96+Ngk tgHtu7b+EdDy9eh8dtjlfEe2R1bMFks90B9zCwh0MNFvle8gaM4ZpIO4a0SuUl4tw7mfzO V8HlvQ4XHpsGX2u8TTIk6hv5t3dxAxHWO+HAoJGhdNfnf/jYl3aaRzwjaj+pcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Yv2md2TDtzvq8; Thu, 13 Feb 2025 17:51:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51DHpTXJ069187; Thu, 13 Feb 2025 17:51:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51DHpTDp069185; Thu, 13 Feb 2025 17:51:29 GMT (envelope-from git) Date: Thu, 13 Feb 2025 17:51:29 GMT Message-Id: <202502131751.51DHpTDp069185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: ac2170b99551 - stable/14 - pac: Use strdup and asprintf in place of dubious string building List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: ac2170b9955134c66f0e820b9dc1daa8f4d0e6a3 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ac2170b9955134c66f0e820b9dc1daa8f4d0e6a3 commit ac2170b9955134c66f0e820b9dc1daa8f4d0e6a3 Author: John Baldwin AuthorDate: 2025-01-03 15:39:44 +0000 Commit: John Baldwin CommitDate: 2025-02-13 16:01:19 +0000 pac: Use strdup and asprintf in place of dubious string building GCC 14 warned about transposed arguments to calloc, but these cases are better served by more abstract string functions. (cherry picked from commit f94513a3a36b50823c3918c93ee5c6bf5f525e91) --- usr.sbin/lpr/pac/pac.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c index 85c9327f433f..5eb5cab02353 100644 --- a/usr.sbin/lpr/pac/pac.c +++ b/usr.sbin/lpr/pac/pac.c @@ -339,8 +339,7 @@ enter(const char name[]) h = hash(name); hcount++; hp = (struct hent *) calloc(sizeof *hp, (size_t)1); - hp->h_name = (char *) calloc(sizeof(char), strlen(name)+1); - strcpy(hp->h_name, name); + hp->h_name = strdup(name); hp->h_feetpages = 0.0; hp->h_count = 0; hp->h_link = hashtab[h]; @@ -441,10 +440,8 @@ chkprinter(const char *ptrname) errx(3, "accounting not enabled for printer %s", ptrname); if (!pflag && pp->price100) price = pp->price100/10000.0; - sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5); + asprintf(&sumfile, "%s_sum", acctfile); if (sumfile == NULL) - errx(1, "calloc failed"); - strcpy(sumfile, acctfile); - strcat(sumfile, "_sum"); + errx(1, "asprintf failed"); return(1); }