Fix building of registration entry in build_peer when using callbackextension
authorJeff Peeler <jpeeler@digium.com>
Mon, 28 Sep 2009 19:10:10 +0000 (19:10 +0000)
committerJeff Peeler <jpeeler@digium.com>
Mon, 28 Sep 2009 19:10:10 +0000 (19:10 +0000)
Check for remotesecret option was unintentionally always true, which therefore
caused the secret option to never be used. Thanks to dvossel for pointing out
the exact fix.

(closes issue #15943)
Reported by: tpsast

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@220718 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 08f2128..731453f 100644 (file)
@@ -24641,7 +24641,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
        ast_free_ha(oldha);
        if (!ast_strlen_zero(callback)) { /* build string from peer info */
                char *reg_string;
-               if (asprintf(&reg_string, "%s?%s:%s@%s/%s", peer->name, peer->username, peer->remotesecret ? peer->remotesecret : peer->secret, peer->tohost, callback) < 0) {
+               if (asprintf(&reg_string, "%s?%s:%s@%s/%s", peer->name, peer->username, !ast_strlen_zero(peer->remotesecret) ? peer->remotesecret : peer->secret, peer->tohost, callback) < 0) {
                        ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
                } else  if (reg_string) {
                        sip_register(reg_string, 0); /* XXX TODO: count in registry_count */