Module: kamailio Branch: master Commit: 18bd172382f927a771b3b6ef05d614a3562c0202 URL: https://github.com/kamailio/kamailio/commit/18bd172382f927a771b3b6ef05d614a3562c0202
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2025-08-16T08:01:50+02:00 microhttpd: clone header name for search - GH #4369 --- Modified: src/modules/microhttpd/microhttpd_mod.c --- Diff: https://github.com/kamailio/kamailio/commit/18bd172382f927a771b3b6ef05d614a3562c0202.diff Patch: https://github.com/kamailio/kamailio/commit/18bd172382f927a771b3b6ef05d614a3562c0202.patch --- diff --git a/src/modules/microhttpd/microhttpd_mod.c b/src/modules/microhttpd/microhttpd_mod.c index 665e61cd375..615bd0171ec 100644 --- a/src/modules/microhttpd/microhttpd_mod.c +++ b/src/modules/microhttpd/microhttpd_mod.c @@ -270,6 +270,7 @@ int pv_get_mhttpd(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) { struct sockaddr *srcaddr = NULL; const char *hdrval = NULL; + char hname[256]; if(param == NULL) { return -1; @@ -278,8 +279,16 @@ int pv_get_mhttpd(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) return pv_get_null(msg, param, res); } if(param->pvn.u.isname.type == PVT_HDR) { - hdrval = MHD_lookup_connection_value(_ksr_mhttpd_ctx.connection, - MHD_HEADER_KIND, param->pvn.u.isname.name.s.s + 2); + if(param->pvn.u.isname.name.s.len >= 256) { + LM_ERR("header name too long: %d\n", + param->pvn.u.isname.name.s.len); + return pv_get_null(msg, param, res); + } + memcpy(hname, param->pvn.u.isname.name.s.s + 2, + param->pvn.u.isname.name.s.len - 2); + hname[param->pvn.u.isname.name.s.len - 2] = '\0'; + hdrval = MHD_lookup_connection_value( + _ksr_mhttpd_ctx.connection, MHD_HEADER_KIND, hname); if(hdrval == NULL) { return pv_get_null(msg, param, res); } _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-le...@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!