Wed, 16 May 2018 13:13:33 +0200
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;