diff mbox series

[OpenWrt-Devel,1/1] uclient-http: Close ustream file handle only if allocated

Message ID 20180803213921.25481-2-tobleminer@gmail.com
State Accepted
Headers show
Series uclient-http: Close ustream file handle only if allocated | expand

Commit Message

Tobias Schramm Aug. 3, 2018, 9:39 p.m. UTC
Since the connection setup in uclient_do_connect can fail before
ustream_init_fd is called we must check the fd was actually allocated
before closing it, else we would close STDIN.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
---
 uclient-http.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jo-Philipp Wich Aug. 3, 2018, 9:46 p.m. UTC | #1
Merged into project/uclient.git, branch master at
http://git.openwrt.org/?p=project/uclient.git.

Thank you!
diff mbox series

Patch

diff --git a/uclient-http.c b/uclient-http.c
index ebe7758..8d6d327 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -149,7 +149,8 @@  static void uclient_http_disconnect(struct uclient_http *uh)
 	if (uh->ssl)
 		ustream_free(&uh->ussl.stream);
 	ustream_free(&uh->ufd.stream);
-	close(uh->ufd.fd.fd);
+	if(uh->ufd.fd.fd)
+		close(uh->ufd.fd.fd);
 	uh->us = NULL;
 }