[njs] A fix of possible sign extension overflow,

Igor Sysoev igor at sysoev.ru
Sun Sep 25 16:11:28 UTC 2016


details:   http://hg.nginx.org/njs/rev/5ef1091ecfaf
branches:  
changeset: 181:5ef1091ecfaf
user:      Igor Sysoev <igor at sysoev.ru>
date:      Sun Sep 25 10:54:51 2016 +0300
description:
A fix of possible sign extension overflow,
the issue has been found by Coverity Scan.

diffstat:

 nxt/nxt_array.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r 6a983847db14 -r 5ef1091ecfaf nxt/nxt_array.c
--- a/nxt/nxt_array.c	Sat Sep 24 22:13:31 2016 +0300
+++ b/nxt/nxt_array.c	Sun Sep 25 10:54:51 2016 +0300
@@ -113,7 +113,7 @@ nxt_array_add_multiple(nxt_array_t *arra
         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 *arra
         }
     }
 
-    item = (char *) array->start + array->items * array->item_size;
+    item = (char *) array->start + (uint32_t) array->items * array->item_size;
 
     array->items = items;
 



More information about the nginx-devel mailing list