From c1fcb8379c24efed52f6dca2f3f00f6ee5d43706 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 30 Mar 2021 11:58:11 +0200 Subject: [PATCH] core: dset - asume udp if uri without transport for alias encoding - set output length for udp proto --- src/core/dset.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/dset.c b/src/core/dset.c index 12521350438..adabe7bba00 100644 --- a/src/core/dset.c +++ b/src/core/dset.c @@ -1153,7 +1153,7 @@ int ksr_uri_alias_encode(str *iuri, str *ualias) p += 4; } *p++ = '~'; - *p++ = puri.proto + '0'; + *p++ = ((puri.proto)?puri.proto:1) + '0'; ualias->len = p - ualias->s; ualias->s[ualias->len] = '\0'; @@ -1204,6 +1204,9 @@ int ksr_uri_alias_decode(str *ualias, str *ouri) goto error; } nproto = *p - '0'; + if(nproto == PROTO_NONE) { + nproto = PROTO_UDP; + } if (nproto != PROTO_UDP) { proto_type_to_str(nproto, &sproto); if (sproto.len == 0) { @@ -1214,11 +1217,13 @@ int ksr_uri_alias_decode(str *ualias, str *ouri) p += 10; memcpy(p, sproto.s, sproto.len); p += sproto.len; - *p = '\0'; - ouri->len = (int)(p - ouri->s); - ouri->s[ouri->len] = '\0'; - break; + } else { + /* go back one byte to overwrite ';' */ + p--; } + ouri->len = (int)(p - ouri->s); + ouri->s[ouri->len] = '\0'; + break; } else { LM_ERR("invalid number of separators (%d)\n", n); goto error;