From: Adam Sutton Date: Sun, 10 Jan 2016 00:25:23 +0000 (+0000) Subject: cwc: don't assign possible -ve return to unsigned type and check for <= 0 X-Git-Tag: v4.2.1~1163^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29025b1dad34b75be444ab9939c6e6215721d258;p=thirdparty%2Ftvheadend.git cwc: don't assign possible -ve return to unsigned type and check for <= 0 Depdending on how the compiler treats this you "might" get away with it, but bad practice and not suprisingly it confused coverity. --- diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index 23dca7584..24c071148 100644 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -402,7 +402,7 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 { cwc_message_t *cm = malloc(sizeof(cwc_message_t)); uint8_t *buf = cm->cm_data; - int seq; + int seq, ret; if (len < 3 || len + 12 > CWS_NETMSGSIZE) { free(cm); @@ -427,10 +427,11 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 // adding packet header size len += 12; - if((len = des_encrypt(buf, len, cwc)) <= 0) { + if((ret = des_encrypt(buf, len, cwc)) <= 0) { free(cm); return -1; } + len = (size_t)ret; tvhtrace("cwc", "sending message sid %d len %zu enq %d", sid, len, enq); tvhlog_hexdump("cwc", buf, len);