mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	Fix parsing of SIP headers where compact and non-compact headers are mixed
Change parsing of SIP headers so that compactness of the header no longer influences which header will be chosen. Previously, a non-compact header would be chosen instead of a preceeding compact-form header. (closes issue ASTERISK-17192) Review: https://reviewboard.asterisk.org/r/1728/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@354702 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -7331,8 +7331,6 @@ static const char *find_alias(const char *name, const char *_default) | |||||||
| 
 | 
 | ||||||
| static const char *__get_header(const struct sip_request *req, const char *name, int *start) | static const char *__get_header(const struct sip_request *req, const char *name, int *start) | ||||||
| { | { | ||||||
| 	int pass; |  | ||||||
| 
 |  | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * Technically you can place arbitrary whitespace both before and after the ':' in | 	 * Technically you can place arbitrary whitespace both before and after the ':' in | ||||||
| 	 * a header, although RFC3261 clearly says you shouldn't before, and place just | 	 * a header, although RFC3261 clearly says you shouldn't before, and place just | ||||||
| @@ -7342,23 +7340,26 @@ static const char *__get_header(const struct sip_request *req, const char *name, | |||||||
| 	 * Anyways, pedanticsipchecking controls whether we allow spaces before ':', | 	 * Anyways, pedanticsipchecking controls whether we allow spaces before ':', | ||||||
| 	 * and we always allow spaces after that for compatibility. | 	 * and we always allow spaces after that for compatibility. | ||||||
| 	 */ | 	 */ | ||||||
| 	for (pass = 0; name && pass < 2;pass++) { | 	const char *sname = find_alias(name, NULL); | ||||||
| 		int x, len = strlen(name); | 	int x, len = strlen(name), slen = (sname ? 1 : 0); | ||||||
| 		for (x = *start; x < req->headers; x++) { | 	for (x = *start; x < req->headers; x++) { | ||||||
| 			const char *header = REQ_OFFSET_TO_STR(req, header[x]); | 		const char *header = REQ_OFFSET_TO_STR(req, header[x]); | ||||||
| 			if (!strncasecmp(header, name, len)) { | 		int smatch = 0, match = !strncasecmp(header, name, len); | ||||||
| 				const char *r = header + len;	/* skip name */ | 		if (slen) { | ||||||
| 				if (sip_cfg.pedanticsipchecking) | 			smatch = !strncasecmp(header, sname, slen); | ||||||
| 					r = ast_skip_blanks(r); | 		} | ||||||
|  | 		if (match || smatch) { | ||||||
|  | 			/* skip name */ | ||||||
|  | 			const char *r = header + (match ? len : slen ); | ||||||
|  | 			if (sip_cfg.pedanticsipchecking) { | ||||||
|  | 				r = ast_skip_blanks(r); | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 				if (*r == ':') { | 			if (*r == ':') { | ||||||
| 					*start = x+1; | 				*start = x+1; | ||||||
| 					return ast_skip_blanks(r+1); | 				return ast_skip_blanks(r+1); | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if (pass == 0) /* Try aliases */ |  | ||||||
| 			name = find_alias(name, NULL); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Don't return NULL, so get_header is always a valid pointer */ | 	/* Don't return NULL, so get_header is always a valid pointer */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user