From nobody Thu Aug 01 16:16:50 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 4WZYxv1Ctwz5T0Yk; Thu, 01 Aug 2024 16:16:51 +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 4WZYxt5m11z4gDs; Thu, 1 Aug 2024 16:16:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722529010; 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=IKhvyNAtOuuVyEug2Y2JomZOqPIaBpDgqIvzDQX2zcY=; b=LjlqCGUVP4LpbBd1s7PJZhZYnZFq2EflAqDVIM571PKeMbGMzbAX1cZNAm1oqeKWU5VGsC iRjW34upQGqR2IbDTjFFx5SxxEH40OdztkmXck/ipvE0S2qclG/HEL3hSrmlXa//Gb64E8 aDjoBJ/XXIrYm3UBZsczgp1EZIA59MfOgFjv63JPlPVLh9afCsjNkAvlFQheThA3BunbAq JW9Td+DrhrqTmm938n+kQlSPkc4TZquDF/SmrHnk0ywiFg5wIkG7NowK0dt2TSOBgQNjQl PRh66Yx7pduJhX3kettlkeLAUonPdDNSxowS5Jq8WBrecWGACJKoBfvj74sNEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722529010; a=rsa-sha256; cv=none; b=jHBlZUa1sycc7Yc89w009lb7Ijy4ezRbPuFPJ0FQYxHtOA7RbgrKCGoqOXlF2B0vGwxDIn WnrnZksEyaaX2deNLYqfaXt0zww1GwzjTIrtG1evNBXCUnfDNwMyARjB1JCcYMBNhmI7ff 69KT2ZztiCt4CnS+8eQ/0zPMaYo8Rwd13d8j3wVNsl9cTZ+QLFd6AuieZC1RqFc+xIeWJj rnSoZhOx0oHpTUPOiZQ52Hj6HXxHzQjNhrM2SBad15Txi0zDPc7/9uMlQFtWAt3Y58EveQ YY32tkdiKCOqow5QdbxUyjOgruJzjHRJP2GOmBl06Wh2uJX8beN+D5ztQYihXQ== 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=1722529010; 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=IKhvyNAtOuuVyEug2Y2JomZOqPIaBpDgqIvzDQX2zcY=; b=M1am7npredFewiwkYmTQEC7oC/2tbai/0tThfwA52TF6nMhFBuTsBkOrvjkq478pRR9k/i okKNfv+lZZb5A/UuYCeOi1hpGQwYXBPjLnan+9zwse5EKMFgVxN32AS9uSLEioa1kmEFok ss+7Hrim62MD52TNBrQ08kR8C7h4KJzjw4BVpXDLunBEns3QCtz+c4T3wqeJ45yObLaHWH TmLplznsLBu4NEqQrdlKTKUnbMMn7wj9/wkehA7qL2v5XYrPZkZ7nM3rdpIRt/TgPzUCtT m9biMecKVnEHQmiTxT+yjo9jBAa1WdrHVT+Ll/GqMTPFZFUr/tYV8V0riOHhrw== 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 4WZYxt5Mwtzrbg; Thu, 1 Aug 2024 16:16:50 +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 471GGo7t095742; Thu, 1 Aug 2024 16:16:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471GGoO5095739; Thu, 1 Aug 2024 16:16:50 GMT (envelope-from git) Date: Thu, 1 Aug 2024 16:16:50 GMT Message-Id: <202408011616.471GGoO5095739@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: ece4e05f4bf9 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: ece4e05f4bf96a5bd2dad61ad057aa076ae5dc36 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=ece4e05f4bf96a5bd2dad61ad057aa076ae5dc36 commit ece4e05f4bf96a5bd2dad61ad057aa076ae5dc36 Author: Dag-Erling Smørgrav AuthorDate: 2024-07-24 20:06:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-08-01 16:15:57 +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 */