]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
cwc: don't assign possible -ve return to unsigned type and check for <= 0
authorAdam Sutton <dev@adamsutton.me.uk>
Sun, 10 Jan 2016 00:25:23 +0000 (00:25 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Sun, 10 Jan 2016 18:01:33 +0000 (18:01 +0000)
Depdending on how the compiler treats this you "might" get away with it, but
bad practice and not suprisingly it confused coverity.

src/descrambler/cwc.c

index 23dca75844daa0a335d5fb0a625c465556054fa6..24c0711487d7793def3c04145af9e1ed430fbff2 100644 (file)
@@ -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);