Fix off by 1 error
i can increment > qs_kv_size with some inputs. Fix this
by incrementing earlier in the loop instead so we don't
have to increment after the loop and possibly go past
max.
Tested: Used bad string and no longer saw segfault
Change-Id: Ia68cd9b24e9a0b16646197983c513d78df2239ed
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/http/query_string.h b/http/query_string.h
index 1cc68fb..6fed49a 100644
--- a/http/query_string.h
+++ b/http/query_string.h
@@ -155,16 +155,14 @@
i = 0;
while (i < qs_kv_size)
{
- qs_kv[i] = substrPtr;
+ qs_kv[i++] = substrPtr;
j = strcspn(substrPtr, "&");
if (substrPtr[j] == '\0')
{
break;
}
substrPtr += j + 1;
- i++;
}
- i++; // x &'s -> means x iterations of this loop -> means *x+1* k/v pairs
// we only decode the values in place, the keys could have '='s in them
// which will hose our ability to distinguish keys from values later