public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>,
	passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Subject: Re: [PATCH 1/5] util: Be more defensive about buffer overruns in read_file()
Date: Tue, 6 Jan 2026 14:37:09 +0100	[thread overview]
Message-ID: <4bd76111-9b96-4eaf-88bc-827f39bd2d20@redhat.com> (raw)
In-Reply-To: <20260105075337.1724962-2-david@gibson.dropbear.id.au>

On 1/5/26 08:53, David Gibson wrote:
> clang-21.1.7 complains about read_file(), thinking that total_read might
> come to exceed buf_size, leading to an out of bounds access at the end of
> the function.  In fact, the semantics of read()'s return mean this can't
> ever happen.  But we already have to check for the total_read == buf_size
> case, so it's basically free to change it to >= and suppress the error.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>   util.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/util.c b/util.c
> index 27303950..a48f727c 100644
> --- a/util.c
> +++ b/util.c
> @@ -715,7 +715,7 @@ static ssize_t read_file(const char *path, char *buf, size_t buf_size)
>   
>   	close(fd);
>   
> -	if (total_read == buf_size) {
> +	if (total_read >= buf_size) {
>   		buf[buf_size - 1] = '\0';
>   		return -ENOBUFS;
>   	}

Reviewed-by: Laurent Vivier <lvivier@redhat.com>


  reply	other threads:[~2026-01-06 13:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05  7:53 [PATCH 0/5] Fixes for Fedora 43 (or other bitrot) David Gibson
2026-01-05  7:53 ` [PATCH 1/5] util: Be more defensive about buffer overruns in read_file() David Gibson
2026-01-06 13:37   ` Laurent Vivier [this message]
2026-01-05  7:53 ` [PATCH 2/5] migrate: Don't use terminator element for versions[] array David Gibson
2026-01-06 13:43   ` Laurent Vivier
2026-01-06 13:47   ` Laurent Vivier
2026-01-07  0:10     ` David Gibson
2026-01-05  7:53 ` [PATCH 3/5] treewide: Don't rely on terminator records in ip[46].dns arrays David Gibson
2026-01-06 13:53   ` Laurent Vivier
2026-01-07  0:11     ` David Gibson
2026-01-05  7:53 ` [PATCH 4/5] test: Handle Operating System Command escapes in terminal output David Gibson
2026-01-06 14:07   ` Laurent Vivier
2026-01-05  7:53 ` [PATCH 5/5] test: Include sshd-auth in mbuto guest image David Gibson
2026-01-06 14:11   ` Laurent Vivier

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=4bd76111-9b96-4eaf-88bc-827f39bd2d20@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).