]> git.kaiwu.me - njs.git/commitdiff
A fix of possible sign extension overflow,
authorIgor Sysoev <igor@sysoev.ru>
Sun, 25 Sep 2016 07:54:51 +0000 (10:54 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 25 Sep 2016 07:54:51 +0000 (10:54 +0300)
the issue has been found by Coverity Scan.

nxt/nxt_array.c

index 9f1da8afd04e9f9f97bd9c76f3cfd8c73a7ff9cd..f9c3e89ca3b18a3a61c429c5906b40588614eb04 100644 (file)
@@ -113,7 +113,7 @@ nxt_array_add_multiple(nxt_array_t *array, const nxt_mem_proto_t *proto,
         old = array->start;
         array->start = start;
 
-        memcpy(start, old, array->items * array->item_size);
+        memcpy(start, old, (uint32_t) array->items * array->item_size);
 
         if (array->separate == 0) {
             array->separate = 1;
@@ -123,7 +123,7 @@ nxt_array_add_multiple(nxt_array_t *array, const nxt_mem_proto_t *proto,
         }
     }
 
-    item = (char *) array->start + array->items * array->item_size;
+    item = (char *) array->start + (uint32_t) array->items * array->item_size;
 
     array->items = items;