From nobody Thu Aug 01 16:46:53 2024 X-Original-To: dev-commits-src-branches@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 4WZZcY690jz5T32J; Thu, 01 Aug 2024 16:46:53 +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 4WZZcY54h4z4mlZ; Thu, 1 Aug 2024 16:46:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722530813; 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=02f/17IhFAxoxDiz+/DnJ3ykvOggx4A6+nZicqaWZAc=; b=PKzGfAMrCzdfNNxCY73pYSNO9GLSFJZ7ibtkFaVTFJVE6SHb99GhXSlu50yOueKN4pCIv/ cH9MihAL+S1GN1in7NKjCA/kS+o30XDQMHw6qW+0LHnAj8KptDl1cY2brT1pZqyuYBhOGs 8QgtvoLm8GWd0ioRTJjAAvaX0eO6rcBGSjqpkPk3EAYYemH1UoQVmr0/sgatHJmgbNaOns DMJ95Ewdfu1jn+dySwRtSeuqehKtt9TBujschRhO3+RL5n7mXjNaZKtzlXtO4/7c8+yJcx XBj4wETDDBzTFXsa+2eSfxLnxJ49SuxscNzQm9fS8OlkmS1HvGEs0oFJKxTniQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722530813; a=rsa-sha256; cv=none; b=fzil5S4vSnoLRbZqxnHJqsXVFZYPzCWNxvz5bV5f17EAxfRlthZ9IUcZyQFTtegd+sWsNt IYpzhJQlXyEHftCuAGsH1DAOSvGIII2BEtSMBaBInMFeF3jUYDqrMgJB0Nc4eLick08bgX VNzd6jNv8v5TqEtiGA6TjdaaHKYTYneKe4WaFQC2AFxYZ9CVSt3wRUTvCC1ZtWtoDBYsFX D4nfun5Cf3OPeTZlgxzusJZeiNG/Pg5DHJf2WsehxeSNeEiaY2aPU3RrkOHBcLJrdIDcnU Cq+Tf+WJbWPt/O00JCGDWNFpuewhP9L9DLmP9hrLJmG3c8/HqvEiGlqYtdObUg== 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=1722530813; 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=02f/17IhFAxoxDiz+/DnJ3ykvOggx4A6+nZicqaWZAc=; b=WudgGcJMzfk0etramTKWPmHEGHRVFHTLFL+yVNMoerZgq4jW2Bpxl/H4HtrJnkFk7Y5Csx 22t1qgmKMeEud8HmdSMj9NjqICdpS3RPel8PInzUDa4jX+hyJIgLPkiyEL3ycG4q0QqxvM poW0PaodvvN3rTYi5oxONUMHRGp07EtorAM2vqCROXCx5vf9goB9jEhNTbfyNI+iuKe/d2 h7D+VNIcXi4KnSzUaD3+9rVGx2GsyVKsbWK3nwV1a2kIGSZk4l+oeR/FX3ENYihY52pWho hHvCHPGYWwtkuihqgCq5Yfd+5fAlhkP+sJiRxtaUdulpexKJKtKkGu38UFkWhQ== 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 4WZZcY4PtjzsFN; Thu, 1 Aug 2024 16:46:53 +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 471GkrKc046514; Thu, 1 Aug 2024 16:46:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471Gkrwp046511; Thu, 1 Aug 2024 16:46:53 GMT (envelope-from git) Date: Thu, 1 Aug 2024 16:46:53 GMT Message-Id: <202408011646.471Gkrwp046511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: b7834095749d - stable/13 - pax: Clear arcn in each read function. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: b7834095749d56d7d35871918ed371f133fcb624 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b7834095749d56d7d35871918ed371f133fcb624 commit b7834095749d56d7d35871918ed371f133fcb624 Author: Dag-Erling Smørgrav AuthorDate: 2024-07-24 20:06:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-08-01 16:42:34 +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 (cherry picked from commit f890020d43bf2070f12ffec37bcd9579f6fb1347) --- 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 76edca3c6f91..0b5b95bb5ef5 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -280,13 +280,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); @@ -315,8 +315,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)); } @@ -561,8 +559,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 @@ -609,8 +607,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)); } @@ -857,7 +853,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) { /* @@ -919,8 +915,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 cbe2dbab64f8..785dd32c4838 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -373,9 +373,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 @@ -402,8 +402,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: /* @@ -440,8 +438,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: @@ -449,8 +445,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 @@ -727,10 +721,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; /* @@ -777,15 +770,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 */