[njs] A fix in decodeURI() function.

Igor Sysoev igor at sysoev.ru
Wed Aug 31 16:19:35 UTC 2016


details:   http://hg.nginx.org/njs/rev/584114a51b51
branches:  
changeset: 165:584114a51b51
user:      Igor Sysoev <igor at sysoev.ru>
date:      Wed Aug 31 19:18:47 2016 +0300
description:
A fix in decodeURI() function.

diffstat:

 njs/njs_string.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 76f16f0ef6c5 -r 584114a51b51 njs/njs_string.c
--- a/njs/njs_string.c	Wed Aug 31 17:51:54 2016 +0300
+++ b/njs/njs_string.c	Wed Aug 31 19:18:47 2016 +0300
@@ -2355,7 +2355,10 @@ njs_string_decode(njs_vm_t *vm, njs_valu
         byte = *src++;
 
         if (byte == '%') {
-            if (size < 3) {
+
+            size -= 2;
+
+            if (size == 0) {
                 goto uri_error;
             }
 
@@ -2372,7 +2375,6 @@ njs_string_decode(njs_vm_t *vm, njs_valu
             byte = (d0 << 4) + d1;
 
             if ((reserve[byte >> 5] & ((uint32_t) 1 << (byte & 0x1f))) == 0) {
-                size -= 2;
                 n += 2;
             }
         }



More information about the nginx-devel mailing list