summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c')
-rw-r--r--3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c b/3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c
index 19e3054..d1954f5 100644
--- a/3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c
+++ b/3rdParty/LibMiniUPnPc/src/miniupnpc/portlistingparse.c
@@ -1,11 +1,14 @@
-/* $Id: portlistingparse.c,v 1.6 2012/05/29 10:26:51 nanard Exp $ */
+/* $Id: portlistingparse.c,v 1.10 2016/12/16 08:53:21 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
- * (c) 2011 Thomas Bernard
+ * (c) 2011-2016 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
#include <string.h>
#include <stdlib.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif /* DEBUG */
#include "portlistingparse.h"
#include "minixml.h"
@@ -52,7 +55,7 @@ startelt(void * d, const char * name, int l)
pdata->curelt = PortMappingEltNone;
for(i = 0; elements[i].str; i++)
{
- if(memcmp(name, elements[i].str, l) == 0)
+ if(strlen(elements[i].str) == (size_t)l && memcmp(name, elements[i].str, l) == 0)
{
pdata->curelt = elements[i].code;
break;
@@ -62,7 +65,17 @@ startelt(void * d, const char * name, int l)
{
struct PortMapping * pm;
pm = calloc(1, sizeof(struct PortMapping));
- LIST_INSERT_HEAD( &(pdata->head), pm, entries);
+ if(pm == NULL)
+ {
+ /* malloc error */
+#ifdef DEBUG
+ fprintf(stderr, "%s: error allocating memory",
+ "startelt");
+#endif /* DEBUG */
+ return;
+ }
+ pm->l_next = pdata->l_head; /* insert in list */
+ pdata->l_head = pm;
}
}
@@ -82,7 +95,7 @@ data(void * d, const char * data, int l)
{
struct PortMapping * pm;
struct PortMappingParserData * pdata = (struct PortMappingParserData *)d;
- pm = pdata->head.lh_first;
+ pm = pdata->l_head;
if(!pm)
return;
if(l > 63)
@@ -134,7 +147,6 @@ ParsePortListing(const char * buffer, int bufsize,
struct xmlparser parser;
memset(pdata, 0, sizeof(struct PortMappingParserData));
- LIST_INIT(&(pdata->head));
/* init xmlparser */
parser.xmlstart = buffer;
parser.xmlsize = bufsize;
@@ -150,9 +162,10 @@ void
FreePortListing(struct PortMappingParserData * pdata)
{
struct PortMapping * pm;
- while((pm = pdata->head.lh_first) != NULL)
+ while((pm = pdata->l_head) != NULL)
{
- LIST_REMOVE(pm, entries);
+ /* remove from list */
+ pdata->l_head = pm->l_next;
free(pm);
}
}