Browse code

core: parse via - safe check for end of buffer

- just in case it is needed to be used for non-zero-terminated strings

(cherry picked from commit 1d3fde1205440296c1d6a54feee5a9d637055bee)
(cherry picked from commit 5a73c4b2363a533f8a9ed67aff3413223815c52c)
(cherry picked from commit 0daa378326ea967bda8e302ac183463027b0c0c6)

Daniel-Constantin Mierla authored on 14/09/2021 06:05:05 • Henning Westerholt committed on 22/10/2021 12:12:52
Showing 1 changed files
... ...
@@ -940,7 +940,7 @@ static /*inline*/ char *parse_via_param(char *const p, const char *const end,
940 940
 
941 941
 find_value:
942 942
 	tmp++;
943
-	for(; *tmp; tmp++) {
943
+	for(; tmp<end && *tmp; tmp++) {
944 944
 		switch(*tmp) {
945 945
 			case ' ':
946 946
 			case '\t':
... ...
@@ -2064,7 +2064,7 @@ main_via:
2064 2064
 	tmp++;
2065 2065
 	c_nest = 0;
2066 2066
 	/*state should always be F_HOST here*/;
2067
-	for(; *tmp; tmp++) {
2067
+	for(; tmp<end && *tmp; tmp++) {
2068 2068
 		switch(*tmp) {
2069 2069
 			case ' ':
2070 2070
 			case '\t':