Fix building of registration entry in build_peer when using callbackextension
[asterisk/asterisk.git] / 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 */