public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Aaron Merey <amerey@redhat.com>, elfutils-devel@sourceware.org
Subject: Re: [COMMITTED] debuginfod_find_section: Always update rc with most recent error code
Date: Mon, 07 Nov 2022 15:19:41 +0100	[thread overview]
Message-ID: <d775a1c396ead943d58ee9d260a4a2c3193e442c.camel@klomp.org> (raw)
In-Reply-To: <20221104214018.718373-1-amerey@redhat.com>

Hi Aaron,

On Fri, 2022-11-04 at 17:40 -0400, Aaron Merey via Elfutils-devel
wrote:
> debuginfod_find_section may attempt to download both the debuginfo
> and executable matching the given build-id.  If neither of these
> files can be found, update rc to ensure that we always return an
> accurate error code in this case.

Nicely spotted, otherwise we might have returned -EEXIST.

> diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-
> client.c
> index f48e32cc..99da05ef 100644
> --- a/debuginfod/debuginfod-client.c
> +++ b/debuginfod/debuginfod-client.c
> @@ -1944,7 +1944,8 @@ debuginfod_find_section (debuginfod_client *client,
>  
>    if (rc == -EEXIST)
>      {
> -      /* The section should be found in the executable.  */
> +      /* Either the debuginfo couldn't be found or the section should
> +	 be in the executable.  */
>        fd = debuginfod_find_executable (client, build_id,
>  				       build_id_len, &tmp_path);
>        if (fd > 0)

I know this is in existing code, so this might have missed in a
previous review. But shouldn't this be fd >= 0 ?

That is what is checked in the rest of the code. Except for the
debuginfod_find_section function which uses fd >0 twice.

It is unlikely, but I think fd can be zero if it (stdin) was closed by
the program for some reason. Then I think zero can be reused as new
file descriptor?

Cheers,

Mark

  reply	other threads:[~2022-11-07 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 21:40 Aaron Merey
2022-11-07 14:19 ` Mark Wielaard [this message]
2022-11-07 16:19   ` Aaron Merey

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=d775a1c396ead943d58ee9d260a4a2c3193e442c.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=amerey@redhat.com \
    --cc=elfutils-devel@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).