http: make the RTSP version check stricter
- make it only accept version 1.0, as that is the version curl supports - convert the parser to use strparse - the status code max is now 999, but it does allow != 3 digits Closes #16435
This commit is contained in:
parent
cfc657a48d
commit
4c5099868e
@ -151,6 +151,15 @@ int Curl_str_casecompare(struct Curl_str *str, const char *check);
|
|||||||
Returns true if the provided string in the `str` argument matches the `check`
|
Returns true if the provided string in the `str` argument matches the `check`
|
||||||
string case insensitively.
|
string case insensitively.
|
||||||
|
|
||||||
|
## `Curl_str_cmp`
|
||||||
|
|
||||||
|
~~~c
|
||||||
|
int Curl_str_cmp(struct Curl_str *str, const char *check);
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Returns true if the provided string in the `str` argument matches the `check`
|
||||||
|
string case sensitively. This is *not* the same return code as `strcmp`.
|
||||||
|
|
||||||
## `Curl_str_nudge`
|
## `Curl_str_nudge`
|
||||||
|
|
||||||
~~~c
|
~~~c
|
||||||
|
|||||||
36
lib/http.c
36
lib/http.c
@ -3987,30 +3987,22 @@ static CURLcode http_rw_hd(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
else if(data->conn->handler->protocol & CURLPROTO_RTSP) {
|
else if(data->conn->handler->protocol & CURLPROTO_RTSP) {
|
||||||
const char *p = hd;
|
const char *p = hd;
|
||||||
while(ISBLANK(*p))
|
struct Curl_str ver;
|
||||||
p++;
|
curl_off_t status;
|
||||||
if(!strncmp(p, "RTSP/", 5)) {
|
/* we set the max string a little excessive to forgive some leading
|
||||||
p += 5;
|
spaces */
|
||||||
if(ISDIGIT(*p)) {
|
if(!Curl_str_until(&p, &ver, 32, ' ') &&
|
||||||
p++;
|
!Curl_str_single(&p, ' ') &&
|
||||||
if((p[0] == '.') && ISDIGIT(p[1])) {
|
!Curl_str_number(&p, &status, 999)) {
|
||||||
if(ISBLANK(p[2])) {
|
Curl_str_trimblanks(&ver);
|
||||||
p += 3;
|
if(Curl_str_cmp(&ver, "RTSP/1.0")) {
|
||||||
if(ISDIGIT(p[0]) && ISDIGIT(p[1]) && ISDIGIT(p[2])) {
|
k->httpcode = (int)status;
|
||||||
k->httpcode = (p[0] - '0') * 100 + (p[1] - '0') * 10 +
|
fine_statusline = TRUE;
|
||||||
(p[2] - '0');
|
k->httpversion = 11; /* RTSP acts like HTTP 1.1 */
|
||||||
p += 3;
|
|
||||||
if(ISSPACE(*p)) {
|
|
||||||
fine_statusline = TRUE;
|
|
||||||
k->httpversion = 11; /* RTSP acts like HTTP 1.1 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!fine_statusline)
|
|
||||||
return CURLE_WEIRD_SERVER_REPLY;
|
|
||||||
}
|
}
|
||||||
|
if(!fine_statusline)
|
||||||
|
return CURLE_WEIRD_SERVER_REPLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fine_statusline) {
|
if(fine_statusline) {
|
||||||
|
|||||||
@ -203,6 +203,16 @@ int Curl_str_casecompare(struct Curl_str *str, const char *check)
|
|||||||
return ((str->len == clen) && strncasecompare(str->str, check, clen));
|
return ((str->len == clen) && strncasecompare(str->str, check, clen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* case sensitive string compare. Returns non-zero on match. */
|
||||||
|
int Curl_str_cmp(struct Curl_str *str, const char *check)
|
||||||
|
{
|
||||||
|
if(check) {
|
||||||
|
size_t clen = strlen(check);
|
||||||
|
return ((str->len == clen) && !strncmp(str->str, check, clen));
|
||||||
|
}
|
||||||
|
return !!(str->len);
|
||||||
|
}
|
||||||
|
|
||||||
/* Trim off 'num' number of bytes from the beginning (left side) of the
|
/* Trim off 'num' number of bytes from the beginning (left side) of the
|
||||||
string. If 'num' is larger than the string, return error. */
|
string. If 'num' is larger than the string, return error. */
|
||||||
int Curl_str_nudge(struct Curl_str *str, size_t num)
|
int Curl_str_nudge(struct Curl_str *str, size_t num)
|
||||||
|
|||||||
@ -85,6 +85,7 @@ int Curl_str_newline(const char **linep);
|
|||||||
/* case insensitive compare that the parsed string matches the
|
/* case insensitive compare that the parsed string matches the
|
||||||
given string. */
|
given string. */
|
||||||
int Curl_str_casecompare(struct Curl_str *str, const char *check);
|
int Curl_str_casecompare(struct Curl_str *str, const char *check);
|
||||||
|
int Curl_str_cmp(struct Curl_str *str, const char *check);
|
||||||
|
|
||||||
int Curl_str_nudge(struct Curl_str *str, size_t num);
|
int Curl_str_nudge(struct Curl_str *str, size_t num);
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ OPTIONS
|
|||||||
# Server-side
|
# Server-side
|
||||||
<reply>
|
<reply>
|
||||||
<data>
|
<data>
|
||||||
RTSP/7.1 786
|
RTSP/1.0 786
|
||||||
|
|
||||||
RTSP/
|
RTSP/
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user