overflow of sstrnlen should return SIZE_MAX instead of zero

Wed, 16 May 2018 13:13:33 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 16 May 2018 13:13:33 +0200
changeset 317
ebae0e434898
parent 316
be0f6bd10b52
child 318
348fd9cb7b14

overflow of sstrnlen should return SIZE_MAX instead of zero

src/string.c file | annotate | diff | comparison | revisions
--- a/src/string.c	Mon May 14 19:24:34 2018 +0200
+++ b/src/string.c	Wed May 16 13:13:33 2018 +0200
@@ -73,8 +73,8 @@
 
     for (size_t i = 0 ; i < n ; i++) {
         scstr_t str = va_arg(ap, scstr_t);
-        if(((size_t)-1) - str.length < size) {
-            size = 0;
+        if(SIZE_MAX - str.length < size) {
+            size = SIZE_MAX;
             break;
         }
         size += str.length;

mercurial