From fa20fb2e80246654557b7cccb11f47e753d3069f Mon Sep 17 00:00:00 2001 From: Sebastian Koenig Date: Sat, 10 Sep 2022 08:06:40 -0400 Subject: [PATCH] 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. --- src/modules/module-raop/rtsp-client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/module-raop/rtsp-client.c b/src/modules/module-raop/rtsp-client.c index c731a0469..b9a7913ee 100644 --- a/src/modules/module-raop/rtsp-client.c +++ b/src/modules/module-raop/rtsp-client.c @@ -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) { if (strlen(buf) > 0) { - char *key = buf, *value; + char *key = buf, *value, *end; + size_t len; value = strstr(buf, ":"); if (value == NULL) @@ -317,6 +318,13 @@ static int process_header(struct pw_rtsp_client *client, char *buf) while (*value == ' ') value++; + len = strlen(value); + if (len > 0) { + end = value + len - 1; + while (*end == ' ') + *end-- = '\0'; + } + pw_properties_set(client->headers, key, value); } else {