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

Signed-off-by: Rafał Miłecki <zaj...@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@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to