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

Rafał Miłecki zajec5 at gmail.com
Sun Jul 20 15:58:42 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>
---
 session/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/session/main.c b/session/main.c
index 147c949..e35cd5b 100644
--- a/session/main.c
+++ b/session/main.c
@@ -139,9 +139,16 @@ 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);
+		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