diff options
author | Mihai Richard <mihairichard@live.com> | 2017-01-19 12:51:04 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2017-01-20 11:27:00 +0100 |
commit | 97ac89f9727d4fae1b2d63d2fc3b59e0d5d4bf65 (patch) | |
tree | 8958a043a9e4dadc6f6837cf9ca0e816ba94f7fc | |
parent | ad5333a73b222e95458e05d52f349194df9ae7c6 (diff) | |
download | ubus-97ac89f9727d4fae1b2d63d2fc3b59e0d5d4bf65.tar.gz |
ubusd: fix issue caused by an implicit cast
An -1 returned by ubus_msg_writev() will be interpreted as
UINT_MAX during a check to see how much data had could be
written on the socket.
Because sizeof() will return size_t it will promote the
comparsion to unsigned
Signed-off-by: Mihai Richard <mihairichard@live.com>
-rw-r--r-- | ubusd.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -148,12 +148,13 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free) if (!cl->tx_queue[cl->txq_cur]) { written = ubus_msg_writev(cl->sock.fd, ub, 0); - if (written >= ub->len + sizeof(ub->hdr)) - goto out; if (written < 0) written = 0; + if (written >= ub->len + sizeof(ub->hdr)) + goto out; + cl->txq_ofs = written; /* get an event once we can write to the socket again */ |