diff --git a/upnpreplyparse.c b/upnpreplyparse.c index 5bf5311..36ddef0 100644 --- a/upnpreplyparse.c +++ b/upnpreplyparse.c @@ -47,11 +47,11 @@ NameValueParserStartElt(void * d, const char * name, int l) if(!data->head.lh_first) { struct NameValue * nv; - nv = malloc(sizeof(struct NameValue)); + nv = malloc(sizeof(struct NameValue)+l+1); strcpy(nv->name, "rootElement"); memcpy(nv->value, name, l); nv->value[l] = '\0'; - LIST_INSERT_HEAD( &(data->head), nv, entries); + LIST_INSERT_HEAD(&(data->head), nv, entries); } } @@ -60,14 +60,14 @@ NameValueParserGetData(void * d, const char * datas, int l) { struct NameValueParserData * data = (struct NameValueParserData *)d; struct NameValue * nv; - nv = malloc(sizeof(struct NameValue)); - if(l>511) - l = 511; + if(l>1975) + l = 1975; + nv = malloc(sizeof(struct NameValue)+l+1); strncpy(nv->name, data->curelt, 64); nv->name[63] = '\0'; memcpy(nv->value, datas, l); nv->value[l] = '\0'; - LIST_INSERT_HEAD( &(data->head), nv, entries); + LIST_INSERT_HEAD(&(data->head), nv, entries); } void diff --git a/upnpreplyparse.h b/upnpreplyparse.h index 34f0473..f887046 100644 --- a/upnpreplyparse.h +++ b/upnpreplyparse.h @@ -38,7 +38,7 @@ extern "C" { struct NameValue { LIST_ENTRY(NameValue) entries; char name[64]; - char value[512]; + char value[]; }; struct NameValueParserData {