public inbox for live-patching@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Lawrence <joe.lawrence@redhat.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: live-patching@vger.kernel.org, Song Liu <song@kernel.org>,
	Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Petr Mladek <pmladek@suse.com>
Subject: Re: [PATCH v2 1/5] objtool/klp: Fix mkstemp() failure with long paths
Date: Thu, 5 Feb 2026 10:53:05 -0500	[thread overview]
Message-ID: <aYS84XTYTrjqLcci@redhat.com> (raw)
In-Reply-To: <jwj6k6bbvga3uaaj2hhtau256t7mvcg65wsv5cpsdrx7cpt4zd@knbng27js6t5>

On Wed, Feb 04, 2026 at 08:47:41AM -0800, Josh Poimboeuf wrote:
> On Tue, Feb 03, 2026 at 09:51:36PM -0500, Joe Lawrence wrote:
> > @@ -1219,13 +1221,17 @@ struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name)
> >  
> >  	base = basename(base);
> >  
> > -	tmp_name = malloc(256);
> > +	tmp_name = malloc(PATH_MAX);
> 
> The allocation size can be more precise with something like
> 
> 	tmp_name = malloc(strlen(name) + 8);
> 
> Also, I'm scratching my head at the existing code and wondering why we
> are splitting out the dirname() and the basename() just to paste them
> back together again??  Can you simplify that while you're at it?
> 
> >  	if (!tmp_name) {
> >  		ERROR_GLIBC("malloc");
> >  		return NULL;
> >  	}
> >  
> > -	snprintf(tmp_name, 256, "%s/%s.XXXXXX", dir, base);
> > +	path_len = snprintf(tmp_name, PATH_MAX, "%s/%s.XXXXXX", dir, base);
> > +	if (path_len >= PATH_MAX) {
> > +		ERROR_GLIBC("snprintf");
> > +		return NULL;
> > +	}
> 
> Checking for all the snprintf() cases can be a pain so we have a
> snprintf_check() for a streamlined error checking experience.
> 

Ah, completely missed that, thanks for pointing out.  I'll incorporate
both suggestions into v3.

--
Joe


  reply	other threads:[~2026-02-05 15:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04  2:51 [PATCH v2 0/5] livepatch-klp-build: small fixups and enhancements Joe Lawrence
2026-02-04  2:51 ` [PATCH v2 1/5] objtool/klp: Fix mkstemp() failure with long paths Joe Lawrence
2026-02-04 16:47   ` Josh Poimboeuf
2026-02-05 15:53     ` Joe Lawrence [this message]
2026-02-04  2:51 ` [PATCH v2 2/5] livepatch/klp-build: handle patches that add/remove files Joe Lawrence
2026-02-04 18:02   ` Josh Poimboeuf
2026-02-05 16:35     ` Joe Lawrence
2026-02-05 16:53       ` Josh Poimboeuf
2026-02-10 19:54         ` Joe Lawrence
2026-02-10 20:57           ` Josh Poimboeuf
2026-02-04  2:51 ` [PATCH v2 3/5] livepatch/klp-build: switch to GNU patch and recountdiff Joe Lawrence
2026-02-04  2:58   ` Joe Lawrence
2026-02-04 18:35   ` Josh Poimboeuf
2026-02-05 17:27     ` Joe Lawrence
2026-02-05 17:49       ` Josh Poimboeuf
2026-02-04  2:51 ` [PATCH v2 4/5] livepatch/klp-build: minor short-circuiting tweaks Joe Lawrence
2026-02-04 18:40   ` Josh Poimboeuf
2026-02-05 17:47     ` Joe Lawrence
2026-02-04  2:51 ` [PATCH v2 5/5] livepatch/klp-build: provide friendlier error messages Joe Lawrence

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=aYS84XTYTrjqLcci@redhat.com \
    --to=joe.lawrence@redhat.com \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --cc=song@kernel.org \
    /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