From 237fbf35fc092545e01bb02c90c9169dc91dbb2b Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Sun, 10 Sep 2006 17:35:08 +0000
Subject: [PATCH] If the leading underscore is not stripped before comparison,
 pbx_builtin_getvar_helper() will never find the associated variable. (Bug
 7892)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@42638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 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 4aa88292e2..2f7da5fd23 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -16314,7 +16314,8 @@ static int sip_addheader(struct ast_channel *chan, void *data)
 		no++;
 		snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%.2d", no);
 
-		if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf) == (const char *) NULL) )
+		/* Compare without the leading underscore */
+		if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf + 1) == (const char *) NULL) )
 			ok = TRUE;
 	}
 	if (ok) {
-- 
GitLab