diff mbox series

core: Fix CID 292129 save_stream() fd leak

Message ID 20200409175725.20487-1-toertel@gmail.com
State Accepted
Headers show
Series core: Fix CID 292129 save_stream() fd leak | expand

Commit Message

Mark Jonas April 9, 2020, 5:57 p.m. UTC
0 is a valid file descriptor.

Signed-off-by: Mark Jonas <toertel@gmail.com>
---
 core/stream_interface.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Stefano Babic April 9, 2020, 7 p.m. UTC | #1
On 09/04/20 19:57, Mark Jonas wrote:
> 0 is a valid file descriptor.
> 
> Signed-off-by: Mark Jonas <toertel@gmail.com>
> ---
>  core/stream_interface.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/core/stream_interface.c b/core/stream_interface.c
> index 163c253..0866ecd 100644
> --- a/core/stream_interface.c
> +++ b/core/stream_interface.c
> @@ -454,9 +454,9 @@ static int save_stream(int fdin, struct swupdate_cfg *software)
>  
>  no_copy_output:
>  	free(buf);
> -	if (fdout > 0)
> +	if (fdout >= 0)
>  		close(fdout);
> -	if (tmpfd > 0) {
> +	if (tmpfd >= 0) {
>  		close(tmpfd);
>  		unlink(tmpfilename);
>  	}
> @@ -597,4 +597,3 @@ int get_install_info(sourcetype *source, char *buf, size_t len)
>  
>  	return len;
>  }
> -
> 
Acked-by: Stefano Babic  <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/core/stream_interface.c b/core/stream_interface.c
index 163c253..0866ecd 100644
--- a/core/stream_interface.c
+++ b/core/stream_interface.c
@@ -454,9 +454,9 @@  static int save_stream(int fdin, struct swupdate_cfg *software)
 
 no_copy_output:
 	free(buf);
-	if (fdout > 0)
+	if (fdout >= 0)
 		close(fdout);
-	if (tmpfd > 0) {
+	if (tmpfd >= 0) {
 		close(tmpfd);
 		unlink(tmpfilename);
 	}
@@ -597,4 +597,3 @@  int get_install_info(sourcetype *source, char *buf, size_t len)
 
 	return len;
 }
-