Module: sip-router
Branch: master
Commit: 148d67a8de1524b88b6b3f957baf51e34342e7c8
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=148d67a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Apr 22 16:58:58 2014 +0200
mtree: return 404 if mtree is not found for rpc mtree.summary
---
modules/mtree/mtree_mod.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c
index ea05005..fa7deed 100644
--- a/modules/mtree/mtree_mod.c
+++ b/modules/mtree/mtree_mod.c
@@ -1028,6 +1028,7 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
m_tree_t *pt;
void* th;
void* ih;
+ int found;
if(!mt_defined_trees())
{
@@ -1036,7 +1037,11 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
}
/* read optional tree name */
- rpc->scan(c, "*S", &tname);
+ if(rpc->scan(c, "*S", &tname)==0)
+ {
+ tname.s = NULL;
+ tname.len = 0;
+ }
pt = mt_get_first_tree();
if(pt==NULL)
@@ -1045,12 +1050,14 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
return;
}
+ found = 0;
while(pt!=NULL)
{
if(tname.s==NULL
|| (tname.s!=NULL && pt->tname.len>=tname.len
&& strncmp(pt->tname.s, tname.s, tname.len)==0))
{
+ found = 1;
if (rpc->add(c, "{", &th) < 0)
{
rpc->fault(c, 500, "Internal error creating rpc");
@@ -1082,6 +1089,13 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
}
pt = pt->next;
}
+
+ if(found==0)
+ {
+ rpc->fault(c, 404, "Tree not found");
+ return;
+ }
+
return;
}