From 588045219001373317520c662f71cb866ea1cfef Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 8 Feb 2007 20:03:57 +0000 Subject: [PATCH] fix for SRTP bug reported by christophe * prevents buffer overflow on big messages * sdp parse buffer size increased to 2048 (necessaary?) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@212 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmSdp.cpp | 6 +++++- core/AmSdp.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/AmSdp.cpp b/core/AmSdp.cpp index 70d1af05..e3861db3 100644 --- a/core/AmSdp.cpp +++ b/core/AmSdp.cpp @@ -34,6 +34,7 @@ #include "AmCmd.h" #include "AmUtils.h" #include "AmPlugIn.h" +#include "AmSession.h" #include "amci/amci.h" #include "log.h" @@ -139,7 +140,10 @@ AmSdp::AmSdp(const AmSdp& p_sdp_msg) void AmSdp::setBody(const char* _sdp_msg) { - strcpy(r_buf,_sdp_msg); + if (!memchr(_sdp_msg, '\0', BUFFER_SIZE)) { + throw AmSession::Exception(513, "Message too big"); + } + strcpy(r_buf, _sdp_msg); } diff --git a/core/AmSdp.h b/core/AmSdp.h index 5f5c63e8..5d4ac557 100644 --- a/core/AmSdp.h +++ b/core/AmSdp.h @@ -44,7 +44,7 @@ using std::vector; */ /** Scratch buffer size. */ -#define BUFFER_SIZE 1024 +#define BUFFER_SIZE 2048 /** network type */ enum NetworkType { NT_OTHER=0, NT_IN };