Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 41 additions & 25 deletions netutils/xmlrpc/xmlparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ static int xmlrpc_parseparam(struct parsebuf_s *pbuf)
{
int type;

if (g_xmlcall.argsize >= MAX_ARGS)
{
return XMLRPC_PARSE_ERROR;
}

/* Next, we need a <value> tag */

type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE);
Expand Down Expand Up @@ -228,22 +233,22 @@ static int xmlrpc_parseparam(struct parsebuf_s *pbuf)

switch (g_xmlcall.args[g_xmlcall.argsize])
{
case 'i':
case 'b':
g_xmlcall.arguments[g_xmlcall.argsize].u.i = atoi(g_data);
break;

case 'd':
g_xmlcall.arguments[g_xmlcall.argsize].u.d = atof(g_data);
break;

case 's':
strlcpy(g_xmlcall.arguments[g_xmlcall.argsize].u.string, g_data,
sizeof(g_xmlcall.arguments[g_xmlcall.argsize].u.string));
break;

default:
return XMLRPC_PARSE_ERROR;
case 'i':
case 'b':
g_xmlcall.arguments[g_xmlcall.argsize].u.i = atoi(g_data);
break;

case 'd':
g_xmlcall.arguments[g_xmlcall.argsize].u.d = atof(g_data);
break;

case 's':
strlcpy(g_xmlcall.arguments[g_xmlcall.argsize].u.string, g_data,
sizeof(g_xmlcall.arguments[g_xmlcall.argsize].u.string));
break;

default:
return XMLRPC_PARSE_ERROR;
}

g_xmlcall.argsize++;
Expand Down Expand Up @@ -293,6 +298,10 @@ static int xmlrpc_parseparams(struct parsebuf_s *pbuf)
if ((type == TAG) && (!strncmp(g_data, "<param>", 7)))
{
ret = xmlrpc_parseparam(pbuf);
if (ret < 0)
{
return ret;
}
}
else if ((type == TAG) && (!strncmp(g_data, "</params>", 9)))
{
Expand Down Expand Up @@ -380,16 +389,23 @@ int xmlrpc_parse(int sock, char *buffer)
{
/* Parse the remaining tags within the methodCall tag */

xmlrpc_parsemethod(&pbuf);

/* Check for the closing /methodCall */

type = xmlrpc_getelement(&pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE);
if ((type == TAG) && (!strncmp(g_data, "</methodCall>", 13)))
ret = xmlrpc_parsemethod(&pbuf);
if (ret == XMLRPC_NO_ERROR)
{
/* Successful parse, try to call a user function */

ret = xmlrpc_call(&g_xmlcall);
/* Check for the closing /methodCall */

type = xmlrpc_getelement(&pbuf, g_data,
CONFIG_XMLRPC_STRINGSIZE);
if ((type == TAG) && (!strncmp(g_data, "</methodCall>", 13)))
{
/* Successful parse, try to call a user function */

ret = xmlrpc_call(&g_xmlcall);
}
else
{
ret = XMLRPC_PARSE_ERROR;
}
}
}
}
Expand Down
Loading