From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Utkal Singh <singhutkal015@gmail.com>, linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, yifan.yfzhao@foxmail.com
Subject: Re: [PATCH v3 1/2] erofs-utils: lib/tar: skip PAX entries with empty path
Date: Mon, 16 Mar 2026 16:04:19 +0800 [thread overview]
Message-ID: <48a20201-eec8-4457-91cd-f80634a2267f@linux.alibaba.com> (raw)
In-Reply-To: <20260316075831.35495-2-singhutkal015@gmail.com>
On 2026/3/16 15:58, Utkal Singh wrote:
> When a PAX extended header contains 'path=' with an empty value,
> the computed length becomes zero. The subsequent trailing-slash
> removal loop accesses eh->path[j - 1] where j is zero, resulting
> in an out-of-bounds read and undefined behavior.
>
> Skip such entries to avoid unsafe pointer arithmetic and invalid
> filename handling.
I don't see a reproduciable way here.
>
> Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
> ---
> lib/tar.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/tar.c b/lib/tar.c
> index 26461f8..be86984 100644
> --- a/lib/tar.c
> +++ b/lib/tar.c
> @@ -510,6 +510,8 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios,
>
> if (!strncmp(kv, "path=", sizeof("path=") - 1)) {
> int j = p - 1 - value;
> + if (!j)
> + continue;
> free(eh->path);
> eh->path = strdup(value);
> while (eh->path[j - 1] == '/')
next prev parent reply other threads:[~2026-03-16 8:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 7:58 [PATCH v3 0/2] erofs-utils: lib/tar: fix PAX header parsing issues Utkal Singh
2026-03-16 7:58 ` [PATCH v3 1/2] erofs-utils: lib/tar: skip PAX entries with empty path Utkal Singh
2026-03-16 8:04 ` Gao Xiang [this message]
2026-03-16 8:21 ` Utkal Singh
2026-03-16 7:58 ` [PATCH v3 2/2] erofs-utils: lib/tar: reject negative size= value in PAX header Utkal Singh
2026-03-16 8:03 ` Gao Xiang
2026-03-16 8:20 ` Utkal Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48a20201-eec8-4457-91cd-f80634a2267f@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=singhutkal015@gmail.com \
--cc=xiang@kernel.org \
--cc=yifan.yfzhao@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox