* Store the root XML element when parsing, and make sure we don't write to memory we shouldn't be writing to.

This commit is contained in:
Justin Maggard 2010-06-03 21:59:18 +00:00
parent 047165a502
commit 3673e07cff

View File

@ -16,10 +16,21 @@ static void
NameValueParserStartElt(void * d, const char * name, int l) NameValueParserStartElt(void * d, const char * name, int l)
{ {
struct NameValueParserData * data = (struct NameValueParserData *)d; struct NameValueParserData * data = (struct NameValueParserData *)d;
if(l>511) if(l>63)
l = 511; l = 63;
memcpy(data->curelt, name, l); memcpy(data->curelt, name, l);
data->curelt[l] = '\0'; data->curelt[l] = '\0';
/* store root element */
if(!data->head.lh_first)
{
struct NameValue * nv;
nv = malloc(sizeof(struct NameValue));
strcpy(nv->name, "rootElement");
memcpy(nv->value, name, l);
nv->value[l] = '\0';
LIST_INSERT_HEAD( &(data->head), nv, entries);
}
} }
static void static void