From nobody Wed Jul 24 20:07:10 2024 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 4WTlRM0K6qz5QMq3; Wed, 24 Jul 2024 20:07:11 +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 4WTlRL6vwdz4Xxg; Wed, 24 Jul 2024 20:07:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721851631; 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=U/9G+1X5fF/4O5iAb6klActF2NIX4PcRNqwhJz5uzK0=; b=OHEwIG1uCIXHrLT7XQ0+KCP0oukZ6n8dSXcwm2z/MSX/5Tu7X9EdTlpLtx0f+Os27rZwr0 o50jYtszPhKeYb0Ffyoj7UiYbD84FfzyKVePW9H0l4iM+Yavw9VbRPInpDlXQr9VJMoHfe rH1HlpiWtleVrhhe6mf3VNZJGi7UPRBWA7ADRhW/2OsZ+U8axPAmzjYnYsxR3Fqfi8QEcN BaSbA6nCTchkGIdJl9B4Wl6GKDhz3BC6jiyqLPajqpBsaYFuRuIeoYTzuGzrg8y1GjaQAD gKZCJPNWm2Edyp04KXa5xBuKwPjkIGOJm976i27qoVfOxMTfanxMIXlCQUkiaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721851631; a=rsa-sha256; cv=none; b=Fsnb66Ypev1vWXNPO6A1wzyjQrkbl2yQq7lV8NT0NiaS8PdmlwgvhVI4f7JlTZIqHdLZs/ 0YXnx20ECtAej6ONfcyRMsY+XRHjv/Eq1G2HCDvgiMBhUdnxH5wBK+bIX0+dvxE38KlCjE lQXL53VyNFiQs2t733qjq2n2uy5Uwak8Y7eiqTlMd+5pBG++2BdzyEqKVVx2HNXQ2YzVDK +niqIXDRFROj0UmR5EaFTeXOeRX6VkcdqRzG/thEsTxDr5t88HGmd4y5hqItkJ+vprNshX yZN+d/ilrcCS6mXxbmm4f8eCgoNVdPZU3rJj5LV6jf6yv8jxayWnmgq74hbytg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721851631; 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=U/9G+1X5fF/4O5iAb6klActF2NIX4PcRNqwhJz5uzK0=; b=STAg2akqrWrK4rAVQOI8aCeFJwt6WRWMBGXNzCLpjaGjS09+HKK6Vjw4svGEKy10QeNOMG o2mtMHRlDSipFvxyHf6Q//m9Am3eTrjuEXt5i8jGF2cgyIdsctoN8iMVS1O+fKVDNJfIxJ p9jyXzcpAc+5MTpgbiOUQWrkEAZDtvyKSb2UYGSY3e8aoBXHtgS8LEAYRavrTtblIilDPL CRTAI/Edy/Lh5woY+ULMD1iCLP500eHOyS/URRY518mOnguVb+iBGuVaEV9hUtDzTJUldJ 3zzCCBIJcMoG5NqCgrTTeIHU5rUHBU++GUg7GLU/VXIDkaRnHrr67Owfz0wb8g== 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 4WTlRL6WMgzPvf; Wed, 24 Jul 2024 20:07:10 +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 46OK7AOu046074; Wed, 24 Jul 2024 20:07:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46OK7A4b046068; Wed, 24 Jul 2024 20:07:10 GMT (envelope-from git) Date: Wed, 24 Jul 2024 20:07:10 GMT Message-Id: <202407242007.46OK7A4b046068@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: f890020d43bf - main - pax: Clear arcn in each read function. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f890020d43bf2070f12ffec37bcd9579f6fb1347 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=f890020d43bf2070f12ffec37bcd9579f6fb1347 commit f890020d43bf2070f12ffec37bcd9579f6fb1347 Author: Dag-Erling Smørgrav AuthorDate: 2024-07-24 20:06:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-07-24 20:07:06 +0000 pax: Clear arcn in each read function. Instead of initializing individual fields to zero, clear the entire struct prior to populating it. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: 0mp, markj Differential Revision: https://reviews.freebsd.org/D46097 --- bin/pax/cpio.c | 12 +++--------- bin/pax/tar.c | 20 ++------------------ 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index 8ae40f461343..8108dd11731f 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -274,13 +274,13 @@ cpio_rd(ARCHD *arcn, char *buf) */ if (cpio_id(buf, sizeof(HD_CPIO)) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); hd = (HD_CPIO *)buf; /* * byte oriented cpio (posix) does not have padding! extract the octal * ascii fields from the header */ - arcn->pad = 0L; arcn->sb.st_dev = (dev_t)asc_ul(hd->c_dev, sizeof(hd->c_dev), OCT); arcn->sb.st_ino = (ino_t)asc_ul(hd->c_ino, sizeof(hd->c_ino), OCT); arcn->sb.st_mode = (mode_t)asc_ul(hd->c_mode, sizeof(hd->c_mode), OCT); @@ -309,8 +309,6 @@ cpio_rd(ARCHD *arcn, char *buf) /* * no link name to read for this file */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; return(com_rd(arcn)); } @@ -555,8 +553,8 @@ vcpio_rd(ARCHD *arcn, char *buf) return(-1); } + memset(arcn, 0, sizeof *arcn); hd = (HD_VCPIO *)buf; - arcn->pad = 0L; /* * extract the hex ascii fields from the header @@ -603,8 +601,6 @@ vcpio_rd(ARCHD *arcn, char *buf) /* * we have a valid header (not a link) */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; arcn->pad = VCPIO_PAD(arcn->sb.st_size); return(com_rd(arcn)); } @@ -851,7 +847,7 @@ bcpio_rd(ARCHD *arcn, char *buf) if (bcpio_id(buf, sizeof(HD_BCPIO)) < 0) return(-1); - arcn->pad = 0L; + memset(arcn, 0, sizeof *arcn); hd = (HD_BCPIO *)buf; if (swp_head) { /* @@ -913,8 +909,6 @@ bcpio_rd(ARCHD *arcn, char *buf) /* * we have a valid header (not a link) */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; arcn->pad = BCPIO_PAD(arcn->sb.st_size); return(com_rd(arcn)); } diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 50a9a41623ca..8b551d84ccc3 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -367,9 +367,9 @@ tar_rd(ARCHD *arcn, char *buf) */ if (tar_id(buf, BLKMULT) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); arcn->org_name = arcn->name; arcn->sb.st_nlink = 1; - arcn->pat = NULL; /* * copy out the name and values in the stat buffer @@ -396,8 +396,6 @@ tar_rd(ARCHD *arcn, char *buf) * to encode this as a directory */ pt = &(arcn->name[arcn->nlen - 1]); - arcn->pad = 0; - arcn->skip = 0; switch(hd->linkflag) { case SYMTYPE: /* @@ -434,8 +432,6 @@ tar_rd(ARCHD *arcn, char *buf) arcn->type = PAX_DIR; arcn->sb.st_mode |= S_IFDIR; arcn->sb.st_nlink = 2; - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; break; case AREGTYPE: case REGTYPE: @@ -443,8 +439,6 @@ tar_rd(ARCHD *arcn, char *buf) /* * If we have a trailing / this is a directory and NOT a file. */ - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; if (*pt == '/') { /* * it is a directory, set the mode for -v printing @@ -721,10 +715,9 @@ ustar_rd(ARCHD *arcn, char *buf) */ if (ustar_id(buf, BLKMULT) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); arcn->org_name = arcn->name; arcn->sb.st_nlink = 1; - arcn->pat = NULL; - arcn->nlen = 0; hd = (HD_USTAR *)buf; /* @@ -771,15 +764,6 @@ ustar_rd(ARCHD *arcn, char *buf) if (uid_name(hd->uname, &(arcn->sb.st_uid)) < 0) arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); - /* - * set the defaults, these may be changed depending on the file type - */ - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; - arcn->pad = 0; - arcn->skip = 0; - arcn->sb.st_rdev = (dev_t)0; - /* * set the mode and PAX type according to the typeflag in the header */