diff --git a/miniupnpc-async/upnpreplyparse.c b/miniupnpc-async/upnpreplyparse.c index 5de5796..4d06f05 100644 --- a/miniupnpc-async/upnpreplyparse.c +++ b/miniupnpc-async/upnpreplyparse.c @@ -1,7 +1,8 @@ -/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ -/* MiniUPnP project +/* $Id: upnpreplyparse.c,v 1.20 2017/12/12 11:26:25 nanard Exp $ */ +/* vim: tabstop=4 shiftwidth=4 noexpandtab + * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2015 Thomas Bernard + * (c) 2006-2019 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -26,12 +27,12 @@ NameValueParserStartElt(void * d, const char * name, int l) } static void -NameValueParserEndElt(void * d, const char * name, int l) +NameValueParserEndElt(void * d, const char * name, int namelen) { struct NameValueParserData * data = (struct NameValueParserData *)d; struct NameValue * nv; (void)name; - (void)l; + (void)namelen; if(!data->topelt) return; if(strcmp(data->curelt, "NewPortListing") != 0) @@ -77,6 +78,7 @@ NameValueParserGetData(void * d, const char * datas, int l) if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ + free(data->portListing); data->portListing = malloc(l + 1); if(!data->portListing) { @@ -104,9 +106,7 @@ ParseNameValue(const char * buffer, int bufsize, struct NameValueParserData * data) { struct xmlparser parser; - data->l_head = NULL; - data->portListing = NULL; - data->portListingLength = 0; + memset(data, 0, sizeof(struct NameValueParserData)); /* init xmlparser object */ parser.xmlstart = buffer; parser.xmlsize = bufsize; diff --git a/miniupnpc-libevent/upnpreplyparse.c b/miniupnpc-libevent/upnpreplyparse.c index 5de5796..4d06f05 100644 --- a/miniupnpc-libevent/upnpreplyparse.c +++ b/miniupnpc-libevent/upnpreplyparse.c @@ -1,7 +1,8 @@ -/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ -/* MiniUPnP project +/* $Id: upnpreplyparse.c,v 1.20 2017/12/12 11:26:25 nanard Exp $ */ +/* vim: tabstop=4 shiftwidth=4 noexpandtab + * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2015 Thomas Bernard + * (c) 2006-2019 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -26,12 +27,12 @@ NameValueParserStartElt(void * d, const char * name, int l) } static void -NameValueParserEndElt(void * d, const char * name, int l) +NameValueParserEndElt(void * d, const char * name, int namelen) { struct NameValueParserData * data = (struct NameValueParserData *)d; struct NameValue * nv; (void)name; - (void)l; + (void)namelen; if(!data->topelt) return; if(strcmp(data->curelt, "NewPortListing") != 0) @@ -77,6 +78,7 @@ NameValueParserGetData(void * d, const char * datas, int l) if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ + free(data->portListing); data->portListing = malloc(l + 1); if(!data->portListing) { @@ -104,9 +106,7 @@ ParseNameValue(const char * buffer, int bufsize, struct NameValueParserData * data) { struct xmlparser parser; - data->l_head = NULL; - data->portListing = NULL; - data->portListingLength = 0; + memset(data, 0, sizeof(struct NameValueParserData)); /* init xmlparser object */ parser.xmlstart = buffer; parser.xmlsize = bufsize; diff --git a/miniupnpc/Changelog.txt b/miniupnpc/Changelog.txt index 4130cd3..1e60d0f 100644 --- a/miniupnpc/Changelog.txt +++ b/miniupnpc/Changelog.txt @@ -1,6 +1,9 @@ $Id: Changelog.txt,v 1.237 2019/04/03 15:57:43 nanard Exp $ miniUPnP client Changelog. +2019/04/05: + Fix memory leak in upnpreplyparse.c with NewPortListing element + 2019/03/10: connecthostport.c: Code simplification, error trace fix diff --git a/miniupnpc/upnpreplyparse.c b/miniupnpc/upnpreplyparse.c index 68a47c0..4d06f05 100644 --- a/miniupnpc/upnpreplyparse.c +++ b/miniupnpc/upnpreplyparse.c @@ -1,8 +1,8 @@ -/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ +/* $Id: upnpreplyparse.c,v 1.20 2017/12/12 11:26:25 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2019 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -78,6 +78,7 @@ NameValueParserGetData(void * d, const char * datas, int l) if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ + free(data->portListing); data->portListing = malloc(l + 1); if(!data->portListing) { diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index b24fb74..191a70a 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,5 +1,8 @@ $Id: Changelog.txt,v 1.444 2019/04/03 16:25:53 nanard Exp $ +2019/04/05: + Fix memory leak in upnpreplyparse.c with NewPortListing element + 2019/03/22: netfilter: miniupnpd_functions.sh parsing fix. fix postrouting chain init. diff --git a/miniupnpd/upnpreplyparse.c b/miniupnpd/upnpreplyparse.c index 5921349..4d06f05 100644 --- a/miniupnpd/upnpreplyparse.c +++ b/miniupnpd/upnpreplyparse.c @@ -2,7 +2,7 @@ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2019 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -78,6 +78,7 @@ NameValueParserGetData(void * d, const char * datas, int l) if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ + free(data->portListing); data->portListing = malloc(l + 1); if(!data->portListing) {