mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] read_file_2: Fix return value
@ 2014-09-24  6:49 Teresa Gámez
  2014-09-25  5:44 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Teresa Gámez @ 2014-09-24  6:49 UTC (permalink / raw)
  To: barebox

Set return value correct in error case.
This prevents barebox from crashing in some conditions.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 lib/libfile.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index c6fb6d7..c626e2f 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -163,8 +163,10 @@ again:
 	buf = xzalloc(read_size + 1);
 
 	fd = open(filename, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		ret = fd;
 		goto err_out;
+	}
 
 	ret = read_full(fd, buf, read_size);
 	if (ret < 0)
-- 
1.7.0.4


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] read_file_2: Fix return value
  2014-09-24  6:49 [PATCH] read_file_2: Fix return value Teresa Gámez
@ 2014-09-25  5:44 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2014-09-25  5:44 UTC (permalink / raw)
  To: Teresa Gámez; +Cc: barebox

On Wed, Sep 24, 2014 at 08:49:51AM +0200, Teresa Gámez wrote:
> Set return value correct in error case.
> This prevents barebox from crashing in some conditions.
> 
> Signed-off-by: Teresa Gámez <t.gamez@phytec.de>

Applied, thanks

Sascha

> ---
>  lib/libfile.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/libfile.c b/lib/libfile.c
> index c6fb6d7..c626e2f 100644
> --- a/lib/libfile.c
> +++ b/lib/libfile.c
> @@ -163,8 +163,10 @@ again:
>  	buf = xzalloc(read_size + 1);
>  
>  	fd = open(filename, O_RDONLY);
> -	if (fd < 0)
> +	if (fd < 0) {
> +		ret = fd;
>  		goto err_out;
> +	}
>  
>  	ret = read_full(fd, buf, read_size);
>  	if (ret < 0)
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-25  5:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24  6:49 [PATCH] read_file_2: Fix return value Teresa Gámez
2014-09-25  5:44 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox