From 1499640da9f67e40321b9a86743bc8f8a1f5eb02 Mon Sep 17 00:00:00 2001
From: Sean Bright <sean.bright@gmail.com>
Date: Mon, 25 Mar 2019 15:31:23 -0400
Subject: [PATCH] chan_sip: Ensure 'qualifygap' isn't negative

Passing negative intervals to the scheduler rips a hole in the
space-time continuum.

ASTERISK-25792 #close
Reported by: Paul Sandys

Change-Id: Ie706f21cee05f76ffb6f7d89e9c867930ee7bcd7
---
 channels/chan_sip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index b5ee52e63c..b5bfad4355 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -33182,7 +33182,8 @@ static int reload_config(enum channelreloadreason reason)
 				ast_log(LOG_WARNING, "Usage of SIP_CAUSE is deprecated.  Please use HANGUPCAUSE instead.\n");
 			}
 		} else if (!strcasecmp(v->name, "qualifygap")) {
-			if (sscanf(v->value, "%30d", &global_qualify_gap) != 1) {
+			if (sscanf(v->value, "%30d", &global_qualify_gap) != 1
+				|| global_qualify_gap < 0) {
 				ast_log(LOG_WARNING, "Invalid qualifygap '%s' at line %d of %s\n", v->value, v->lineno, config);
 				global_qualify_gap = DEFAULT_QUALIFY_GAP;
 			}
-- 
GitLab