diff options
author | Jens Georg <mail@jensge.org> | 2021-07-03 19:26:28 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2021-07-03 19:26:28 +0200 |
commit | 0814d52988ae872233d814484d8c5c323b1e5362 (patch) | |
tree | f2901282c986042783c232cc2cb7562c0c35547f | |
parent | 587f3f0e01d4ffd03024a4895f991271abb0b556 (diff) | |
download | gupnp-0814d52988ae872233d814484d8c5c323b1e5362.tar.gz |
service: Validate Host header in GENA handlers
Fixes #55
-rw-r--r-- | libgupnp/gupnp-service.c | 14 |
1 files changed, 14 insertions, 0 deletions
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"); |