miniupnpd: More return value check for malloc() and realloc()
This commit is contained in:
parent
f365c3a9ea
commit
60d1db157a
|
@ -1,4 +1,7 @@
|
||||||
$Id: Changelog.txt,v 1.319 2012/10/23 12:24:31 nanard Exp $
|
$Id: Changelog.txt,v 1.320 2012/12/11 21:07:35 nanard Exp $
|
||||||
|
|
||||||
|
2012/12/11:
|
||||||
|
More return value check for malloc() and realloc()
|
||||||
|
|
||||||
2012/10/23:
|
2012/10/23:
|
||||||
minor modifications to linux/getroute.c and testgetroute.c
|
minor modifications to linux/getroute.c and testgetroute.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: miniupnpd.c,v 1.171 2012/10/04 22:36:46 nanard Exp $ */
|
/* $Id: miniupnpd.c,v 1.172 2012/12/11 21:07:36 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2012 Thomas Bernard
|
* (c) 2006-2012 Thomas Bernard
|
||||||
|
@ -1706,9 +1706,17 @@ main(int argc, char * * argv)
|
||||||
&clientnamelen);
|
&clientnamelen);
|
||||||
syslog(LOG_DEBUG, "sctl! : '%s'", clientname.sun_path);
|
syslog(LOG_DEBUG, "sctl! : '%s'", clientname.sun_path);
|
||||||
tmp = malloc(sizeof(struct ctlelem));
|
tmp = malloc(sizeof(struct ctlelem));
|
||||||
|
if (tmp == NULL)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "Unable to allocate memory for ctlelem in main()");
|
||||||
|
close(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
tmp->socket = s;
|
tmp->socket = s;
|
||||||
LIST_INSERT_HEAD(&ctllisthead, tmp, entries);
|
LIST_INSERT_HEAD(&ctllisthead, tmp, entries);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_EVENTS
|
#ifdef ENABLE_EVENTS
|
||||||
upnpevents_processfds(&readset, &writeset);
|
upnpevents_processfds(&readset, &writeset);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: upnphttp.c,v 1.81 2012/10/04 22:09:34 nanard Exp $ */
|
/* $Id: upnphttp.c,v 1.82 2012/12/11 21:07:37 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* Author : Thomas Bernard
|
* Author : Thomas Bernard
|
||||||
|
@ -637,6 +637,7 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
||||||
void
|
void
|
||||||
Process_upnphttp(struct upnphttp * h)
|
Process_upnphttp(struct upnphttp * h)
|
||||||
{
|
{
|
||||||
|
char * h_tmp;
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
@ -667,10 +668,19 @@ Process_upnphttp(struct upnphttp * h)
|
||||||
const char * endheaders;
|
const char * endheaders;
|
||||||
/* if 1st arg of realloc() is null,
|
/* if 1st arg of realloc() is null,
|
||||||
* realloc behaves the same as malloc() */
|
* realloc behaves the same as malloc() */
|
||||||
h->req_buf = (char *)realloc(h->req_buf, n + h->req_buflen + 1);
|
h_tmp = (char *)realloc(h->req_buf, n + h->req_buflen + 1);
|
||||||
|
if (h_tmp == NULL)
|
||||||
|
{
|
||||||
|
syslog(LOG_WARNING, "Unable to allocate new memory for h->req_buf)");
|
||||||
|
h->state = EToDelete;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
h->req_buf = h_tmp;
|
||||||
memcpy(h->req_buf + h->req_buflen, buf, n);
|
memcpy(h->req_buf + h->req_buflen, buf, n);
|
||||||
h->req_buflen += n;
|
h->req_buflen += n;
|
||||||
h->req_buf[h->req_buflen] = '\0';
|
h->req_buf[h->req_buflen] = '\0';
|
||||||
|
}
|
||||||
/* search for the string "\r\n\r\n" */
|
/* search for the string "\r\n\r\n" */
|
||||||
endheaders = findendheaders(h->req_buf, h->req_buflen);
|
endheaders = findendheaders(h->req_buf, h->req_buflen);
|
||||||
if(endheaders)
|
if(endheaders)
|
||||||
|
|
Loading…
Reference in New Issue