mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: Re: [PATCH 1/2] scripts: imd: fix uninitialized variable read
Date: Mon, 04 May 2020 09:38:22 +0200	[thread overview]
Message-ID: <87mu6o2lqp.fsf@pengutronix.de> (raw)
In-Reply-To: <20200429073807.GE5877@pengutronix.de>


Hi,

Sascha Hauer <s.hauer@pengutronix.de> writes:

> On Wed, Apr 29, 2020 at 08:40:39AM +0200, Ahmad Fatoum wrote:
>> Errors are propagated in the loop and ret is never set. Remove 
>> it.
>> 
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  scripts/bareboximd.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>> 
>> diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
>> index b733cae61c87..d11b661fa391 100644
>> --- a/scripts/bareboximd.c
>> +++ b/scripts/bareboximd.c
>> @@ -53,7 +53,7 @@ int imd_command_setenv(const char 
>> *variable_name, const char *value)
>>  
>>  static int write_file(const char *filename, const void *buf, 
>>  size_t size)
>>  {
>> -	int fd, ret;
>> +	int fd;
>>  	int now;
>>  
>>  	fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR 
>>  | S_IWUSR | S_IRGRP | S_IROTH);
>> @@ -74,9 +74,6 @@ static int write_file(const char *filename, 
>> const void *buf, size_t size)
>>  
>>  	close(fd);
>>  
>> -	if (ret < 0)
>> -		return ret;
>> -
>
> There's more wrong in this function. In the error path the file 
> is never
> closed. It is not an error when write() returns 0. The return 
> value of
> write_file() is never checked by the caller. Steffen, care to 
> fix some
> of these?

yes, I will have a look.


str

-- 
Pengutronix e.K.                | Dipl.-Inform. Steffen Trumtrar |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2020-05-04  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  6:40 Ahmad Fatoum
2020-04-29  6:40 ` [PATCH 2/2] of: fix side effect in macro expansion Ahmad Fatoum
2020-04-29  8:00   ` Sascha Hauer
2020-04-29  8:26     ` Ahmad Fatoum
2020-04-29  8:41       ` Sascha Hauer
2020-04-29  8:47         ` Ahmad Fatoum
2020-04-29  7:38 ` [PATCH 1/2] scripts: imd: fix uninitialized variable read Sascha Hauer
2020-05-04  7:38   ` Steffen Trumtrar [this message]

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=87mu6o2lqp.fsf@pengutronix.de \
    --to=s.trumtrar@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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