[OpenWrt-Devel] [project/ucwmp.git][PATCH V3] session: check for uclient_connect return value

Rafał Miłecki zajec5 at gmail.com
Mon Jul 21 16:05:14 EDT 2014


uclient_connect may return an error and calling uclient_write will cause
a crash

Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
---
V3: Correctly use uloop_end
---
 session/main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/session/main.c b/session/main.c
index 147c949..bf20904 100644
--- a/session/main.c
+++ b/session/main.c
@@ -139,9 +139,17 @@ static void cwmp_dump_message(const char *msg, const char *data)
 static void __cwmp_send_request(struct uloop_timeout *t)
 {
 	int len = 0;
+	int err;
+
 	cwmp_dump_message("Send CPE data", cur_request);
 
-	uclient_connect(uc);
+	err = uclient_connect(uc);
+	if (err) {
+		fprintf(stderr, "Failed to connect to the server: %d\n", err);
+		uloop_end();
+		return;
+	}
+
 	uclient_http_set_request_type(uc, "POST");
 	cwmp_add_cookies(uc);
 
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list