Module: kamailio
Branch: master
Commit: c1fcb8379c24efed52f6dca2f3f00f6ee5d43706
URL:
https://github.com/kamailio/kamailio/commit/c1fcb8379c24efed52f6dca2f3f00f6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-30T11:58:11+02:00
core: dset - asume udp if uri without transport for alias encoding
- set output length for udp proto
---
Modified: src/core/dset.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c1fcb8379c24efed52f6dca2f3f00f6…
Patch:
https://github.com/kamailio/kamailio/commit/c1fcb8379c24efed52f6dca2f3f00f6…
---
diff --git a/src/core/dset.c b/src/core/dset.c
index 1252135043..adabe7bba0 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;