### Description
We noticed random errors from jansson module when:

```
xlog("L_NOTICE", "**** PRE '«$avp(i:901)»' - [% logres %]\n");
jansson_set("str", "cc_sub", "$avp(s:caller_concurrent_calls_count)", 
"$(avp(i:901)[*])");
```

```
May 14 10:11:37 sp1 proxy[23633]: ERROR: jansson [jansson_funcs.c:219]: 
janssonmod_set(): result has json error at line 1: end of file expected near 
'xMTAwMiIsImxucF'                                                               
                       
May 14 10:11:37 sp1 proxy[23633]: ERROR: jansson [jansson_funcs.c:219]: 
janssonmod_set(): result has json error at line 1: end of file expected near '0'
May 14 10:11:37 sp1 proxy[23633]: ERROR: jansson [jansson_funcs.c:219]: 
janssonmod_set(): result has json error at line 1: end of file expected near 
'TEwMDEiLCJkX'
```

### Troubleshooting

#### Reproduction
`` jansson_set(type, key/path, value, result)``

Using a long json result, in my tests longer than 400 chars fires the ERROR

#### Log Messages
```
May 14 10:11:37 sp1 proxy[23633]: NOTICE: <script>: Setting acc destination-leg 
for uuid '«0d5845e9-2cd1-4b1e-bbc4-6ca9102f864e»': '«{"gpp":["long long long 
long","long long long long","long long long long","long long long long","long 
long long long","l
ong long long long","long long long long","long long long long","long long long 
long","long long long 
long"],"plu":0,"s_id":"","c_id":"","a_id":315,"dialed":"4311001","uuid":"0d5845e9-2cd1-4b1e-bbc4-6ca9102f864e","u":"testuser1001","d":"spce.test","u_in
":"4311001","d_in":"spce.test","lcr":0,"lnp_p":"","u_out":"testuser1001","lnp_t":"","fci":"","cc_quota":"","cc_sub":"","cc_cust":""}»'
 - R=«sip:conf=4311001@conference.local» 
ID=«NGCP%invite_conference_update%///1-23982@127.126.0.1_pbx-1» UA='<null>'
May 14 10:11:37 sp1 proxy[23633]: NOTICE: <script>: **** PRE 
'«{"gpp":[null,null,null,null,null,null,null,null,null,null],"clir":0,"uuid":"adeff08b-bd66-4578-8a01-194185d06827","u":"testuser1002","d":"spce.test","cli":"43110011002","s_id":"","c_id":"","
a_id":315,"pau":"","par":"","s":"call","ip":"127.126.0.1","t":1589443897.908021,"lnp_p":"","cli_out":"43110011002","lnp_t":"","pai":"","div":"","cid":"","u2u":"","lcr":0,"cc_quota":"","cc_sub":"","cc_cust":""}»'
 - ID=«NGCP%invite_conference_update%///1-
23982@127.126.0.1_pbx-1» UA='<null>'
May 14 10:11:37 sp1 proxy[23633]: ERROR: jansson [jansson_funcs.c:219]: 
janssonmod_set(): result has json error at line 1: end of file expected near 
'xMTAwMiIsImxucF'
May 14 10:11:37 sp1 proxy[23633]: ERROR: jansson [jansson_funcs.c:219]: 
janssonmod_set(): result has json error at line 1: end of file expected near '0'

```
### Possible Solutions

In my fast check I notice the result is forced to end in '\0'. Preparing a PR 
with a solution.

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

This is Sipwise's version but with no jansson patches at all 

```
version: kamailio 5.3.4 (x86_64/linux) 
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, 
USE_MCAST, NO_SIG_DEBUG, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, 
TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, 
USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, 
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, 
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled with gcc 8.3.0
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2327
_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to