From 4dcf028c215a12d91f5043722b3f3671fd5a0aa5 Mon Sep 17 00:00:00 2001 From: Grzegorz Sluja <grzegorz.sluja@iopsys.eu> Date: Wed, 8 May 2024 09:05:58 +0000 Subject: [PATCH] Fix a crash of buffer overflow caused by a longer session-id value --- configure.ac | 14 +++----------- include/asterisk/cdr.h | 2 +- include/asterisk/stasis_channels.h | 2 +- main/channel_internal_api.c | 2 +- menuselect/configure.ac | 8 -------- res/res_pjsip_session.c | 4 ++-- 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index d3ded27998..377d6c1ce6 100644 --- a/configure.ac +++ b/configure.ac @@ -740,16 +740,6 @@ fi AST_EXT_LIB_CHECK([RT], [rt], [clock_gettime], []) AST_PKG_CONFIG_CHECK([LIBXML2], [libxml-2.0]) -AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , , - [#include <libxml/tree.h> - #include <libxml/parser.h>], - [LIBXML_TEST_VERSION]) - -if test "${PBX_LIBXML2}" != 1; then - AC_MSG_NOTICE(*** The Asterisk menuselect tool requires the 'libxml2' development package.) - AC_MSG_NOTICE(*** Please install the 'libxml2' development package.) - exit 1 -fi AST_EXT_LIB_CHECK([URIPARSER], [uriparser], [uriParseUriA], [uriparser/Uri.h]) @@ -1616,6 +1606,8 @@ fi # do the package library checks now +AST_PKG_CONFIG_CHECK([LIBXML2], [libxml-2.0]) + AST_EXT_LIB_CHECK([ALSA], [asound], [snd_pcm_open], [alsa/asoundlib.h]) AST_EXT_LIB_CHECK([BFD], [bfd], [bfd_openr], [bfd.h]) @@ -2813,7 +2805,7 @@ AC_CHECK_HEADER([linux/compiler.h], AST_C_DEFINE_CHECK([MSG_NOSIGNAL], [MSG_NOSIGNAL], [sys/socket.h]) AST_C_DEFINE_CHECK([SO_NOSIGPIPE], [SO_NOSIGPIPE], [sys/socket.h]) -AST_EXT_TOOL_CHECK([SDL], [sdl-config]) +AST_PKG_CONFIG_CHECK([SDL], [sdl]) AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}]) AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [${PTHREAD_LIBS} -lz -lm], [${PTHREAD_CFLAGS}]) diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h index 6099fa8ac2..807bb2db83 100644 --- a/include/asterisk/cdr.h +++ b/include/asterisk/cdr.h @@ -358,7 +358,7 @@ struct ast_cdr { /*! SessionId */ unsigned int sessionId; /*! SIPSessionID */ - char SIPSessionID[33]; + char SIPSessionID[128]; /*! sipIpAddress */ char sipIpAddress[40]; /*! farEndIPAddress */ diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h index 5a754f6715..0fbab12adb 100644 --- a/include/asterisk/stasis_channels.h +++ b/include/asterisk/stasis_channels.h @@ -158,7 +158,7 @@ struct ast_channel_snapshot { struct varshead *manager_vars; /*!< Variables to be appended to manager events */ struct varshead *ari_vars; /*!< Variables to be appended to ARI events */ unsigned int sessionId; /*!< SessionId */ - char SIPSessionID[33]; /*!< Session-ID */ + char SIPSessionID[128]; /*!< Session-ID */ char sipIpAddress[40]; /*!< SIP IP Address */ char farEndIPAddress[40]; /*!< Far End IP Address */ unsigned int sipResponseCode; /*!< SIP Response Code for Invite */ diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index 543919471a..6f1a778da9 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -225,7 +225,7 @@ struct ast_channel { struct ast_channel_snapshot *snapshot; /*!< The current up to date snapshot of the channel */ struct ast_flags snapshot_segment_flags; /*!< Flags regarding the segments of the snapshot */ unsigned int sessionId; /*!< Session Id from SDP for channel */ - char SIPSessionID[33]; /* SIPSessionID from Session-ID header */ + char SIPSessionID[128]; /* SIPSessionID from Session-ID header */ char sipIpAddress[40]; /*!< local IP address that sip client binds to */ char farEndIPAddress[40]; /*!< Far End IP Address */ unsigned int sipResponseCode; /*!< SIP response Code */ diff --git a/menuselect/configure.ac b/menuselect/configure.ac index 589f0828e0..096d42fec6 100644 --- a/menuselect/configure.ac +++ b/menuselect/configure.ac @@ -92,14 +92,6 @@ else fi AST_PKG_CONFIG_CHECK([LIBXML2], [libxml-2.0]) -AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , , - [#include <libxml/tree.h> - #include <libxml/parser.h>], - [LIBXML_TEST_VERSION]) - -if test "${PBX_LIBXML2}" != 1; then - AC_MSG_ERROR([Could not find required 'Libxml2' development package]) -fi AST_PKG_CONFIG_CHECK([GTK2], [gtk+-2.0]) AC_SUBST(PBX_GTK2) diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 551449d190..0a2b2574ad 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -4798,9 +4798,9 @@ static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_d pjsip_generic_string_hdr *SessionID = NULL; static const pj_str_t headerName = { "Session-ID", 10 }; SessionID = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &headerName, NULL); - char value[33] = {0}; + char value[128] = {0}; if (SessionID) - ast_copy_pj_str(&value, &SessionID->hvalue, pj_strlen(&SessionID->hvalue) + 1); + ast_copy_pj_str(&value, &SessionID->hvalue, sizeof(value)); ast_channel_SIPSessionID_set(session->channel, value); } -- GitLab