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

Daniel-Constantin Mierla authored on 14/09/2021 06:05:05
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':