rtsp-client: remove trailing whitespace from header data

Some clients may send headers with trailing whitespace, which can upset
subsequent parsing of the data into numbers.  This patch removes such trailing
whitespace before further processing the header data.
This commit is contained in:
Sebastian Koenig 2022-09-10 08:06:40 -04:00 committed by Wim Taymans
parent fd66fb8867
commit fa20fb2e80

View file

@ -307,7 +307,8 @@ static void process_received_message(struct pw_rtsp_client *client)
static int process_header(struct pw_rtsp_client *client, char *buf) static int process_header(struct pw_rtsp_client *client, char *buf)
{ {
if (strlen(buf) > 0) { if (strlen(buf) > 0) {
char *key = buf, *value; char *key = buf, *value, *end;
size_t len;
value = strstr(buf, ":"); value = strstr(buf, ":");
if (value == NULL) if (value == NULL)
@ -317,6 +318,13 @@ static int process_header(struct pw_rtsp_client *client, char *buf)
while (*value == ' ') while (*value == ' ')
value++; value++;
len = strlen(value);
if (len > 0) {
end = value + len - 1;
while (*end == ' ')
*end-- = '\0';
}
pw_properties_set(client->headers, key, value); pw_properties_set(client->headers, key, value);
} }
else { else {