miniupnpd: More return value check for malloc() and realloc()
This commit is contained in:
parent
f365c3a9ea
commit
60d1db157a
miniupnpd
|
@ -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:
|
||||
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
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2012 Thomas Bernard
|
||||
|
@ -1706,9 +1706,17 @@ main(int argc, char * * argv)
|
|||
&clientnamelen);
|
||||
syslog(LOG_DEBUG, "sctl! : '%s'", clientname.sun_path);
|
||||
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;
|
||||
LIST_INSERT_HEAD(&ctllisthead, tmp, entries);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_EVENTS
|
||||
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
|
||||
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* Author : Thomas Bernard
|
||||
|
@ -637,6 +637,7 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
|||
void
|
||||
Process_upnphttp(struct upnphttp * h)
|
||||
{
|
||||
char * h_tmp;
|
||||
char buf[2048];
|
||||
int n;
|
||||
|
||||
|
@ -667,10 +668,19 @@ Process_upnphttp(struct upnphttp * h)
|
|||
const char * endheaders;
|
||||
/* if 1st arg of realloc() is null,
|
||||
* 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);
|
||||
h->req_buflen += n;
|
||||
h->req_buf[h->req_buflen] = '\0';
|
||||
}
|
||||
/* search for the string "\r\n\r\n" */
|
||||
endheaders = findendheaders(h->req_buf, h->req_buflen);
|
||||
if(endheaders)
|
||||
|
|
Loading…
Reference in New Issue