Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adamsutton committed Jan 10, 2016
1 parent 5a16608 commit 29025b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/descrambler/cwc.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 29025b1

Please sign in to comment.