From 47ccb01d03e27a36913f763c43da3e7fe7d9c99c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 15 May 2018 18:49:34 +1000 Subject: [PATCH] Avoid negative length values. --- src/generator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generator.c b/src/generator.c index f018a04b..7df505b4 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1835,7 +1835,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) * to avoid sending parts of different messages */ if (proxy->sending && proxy->sending != csmsg) continue; - while (csmsg->len) { + while (csmsg->len > 0) { int fd; if (unlikely(!proxy->alive)) { @@ -1850,7 +1850,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) if (ret < 1) { if (!ret || errno == EAGAIN || errno == EWOULDBLOCK) break; - csmsg->len = 0; + csmsg->len = ret = 0; LOGNOTICE("Proxy %d:%d %s failed to send msg in send_json_msgq, dropping", proxy->id, proxy->subid, proxy->url); set_proxy_disabled(proxy); @@ -1858,7 +1858,7 @@ static void send_json_msgq(cs_msg_t **csmsgq) csmsg->ofs += ret; csmsg->len -= ret; } - if (!csmsg->len) { + if (csmsg->len < 1) { proxy->sending = NULL; DL_DELETE(*csmsgq, csmsg); free(csmsg->buf);