[gupnp: 3/4] service: Validate Host header in GENA handlers
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp: 3/4] service: Validate Host header in GENA handlers
- Date: Sat, 3 Jul 2021 17:37:43 +0000 (UTC)
commit 0814d52988ae872233d814484d8c5c323b1e5362
Author: Jens Georg <mail jensge org>
Date: Sat Jul 3 19:26:28 2021 +0200
service: Validate Host header in GENA handlers
Fixes #55
libgupnp/gupnp-service.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index b441dd1..2a33ea5 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -1379,6 +1379,20 @@ subscription_server_handler (G_GNUC_UNUSED SoupServer *server,
service = GUPNP_SERVICE (user_data);
+ const char *host =
+ soup_message_headers_get_one (msg->request_headers, "Host");
+ GUPnPContext *context = gupnp_service_info_get_context (user_data);
+ if (!gupnp_context_validate_host_header(context, host)) {
+ g_warning ("Host header mismatch, expected %s:%d, got %s",
+ gssdp_client_get_host_ip (GSSDP_CLIENT (context)),
+ gupnp_context_get_port (context),
+ host);
+
+ soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
+
+ return;
+ }
+
callback = soup_message_headers_get_one (msg->request_headers,
"Callback");
nt = soup_message_headers_get_one (msg->request_headers, "NT");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]