Module: sip-router Branch: master Commit: a95cae3fb6a62120b7fe2770fb565195178bb6f7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a95cae3f...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: Mon Mar 24 16:01:44 2014 -0400
ctl: fix crash when listing in struc format - example: kamcmd core.sockets_list
---
modules/ctl/binrpc_run.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/modules/ctl/binrpc_run.c b/modules/ctl/binrpc_run.c index e114c18..bb5fdeb 100644 --- a/modules/ctl/binrpc_run.c +++ b/modules/ctl/binrpc_run.c @@ -1055,11 +1055,12 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) struct binrpc_val avp; struct rpc_struct_l* rs; - memset(&avp, 0, sizeof(struct binrpc_val)); va_start(ap, fmt); for (;*fmt; fmt++){ + memset(&avp, 0, sizeof(struct binrpc_val)); avp.name.s=va_arg(ap, char*); - avp.name.len=strlen(avp.name.s); + if (avp.name.s) + avp.name.len=strlen(avp.name.s); switch(*fmt){ case 'd': case 't': @@ -1070,7 +1071,8 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) case 's': /* asciiz */ avp.type=BINRPC_T_STR; avp.u.strval.s=va_arg(ap, char*); - avp.u.strval.len=strlen(avp.u.strval.s); + if (avp.u.strval.s) + avp.u.strval.len=strlen(avp.u.strval.s); break; case 'S': /* str */ avp.type=BINRPC_T_STR;