Fix off-by-one error when reading SDP sent over TCP.
authorMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 14:59:50 +0000 (14:59 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 14:59:50 +0000 (14:59 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@218499 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 672e668..bd46536 100644 (file)
@@ -2963,7 +2963,7 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi
                if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) {
                        while (cl > 0) {
                                ast_mutex_lock(&tcptls_session->lock);
-                               if (!fread(buf, (cl < sizeof(buf)) ? cl : sizeof(buf), 1, tcptls_session->f)) {
+                               if (!fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f)) {
                                        ast_mutex_unlock(&tcptls_session->lock);
                                        goto cleanup;
                                }