Check for NULL pointer (COverity 4175)

This commit is contained in:
manu 2006-10-02 21:47:32 +00:00
parent e1ade705e1
commit 1966cc3311
2 changed files with 12 additions and 7 deletions

View File

@ -12,6 +12,7 @@
* src/racoon/admin.c: fix memory leak (Coverity) * src/racoon/admin.c: fix memory leak (Coverity)
* src/racoon/algorithm.c: fix array overrun (Coverity) * src/racoon/algorithm.c: fix array overrun (Coverity)
* src/racoon/isakmp_ident.c: Remove dead code (Coverity) * src/racoon/isakmp_ident.c: Remove dead code (Coverity)
* src/racoon/isakmp_inf.c: Check for NULL pointer (Coverity)
2006-10-01 Emmanuel Dreyfus <manu@netbsd.org> 2006-10-01 Emmanuel Dreyfus <manu@netbsd.org>
* src/racoon/isakmp.c: Avoid using NULL pointer (Coverity) * src/racoon/isakmp.c: Avoid using NULL pointer (Coverity)

View File

@ -1,4 +1,4 @@
/* $NetBSD: isakmp_inf.c,v 1.12 2006/09/18 20:32:40 manu Exp $ */ /* $NetBSD: isakmp_inf.c,v 1.13 2006/10/02 21:47:32 manu Exp $ */
/* Id: isakmp_inf.c,v 1.44 2006/05/06 20:45:52 manubsd Exp */ /* Id: isakmp_inf.c,v 1.44 2006/05/06 20:45:52 manubsd Exp */
@ -433,12 +433,16 @@ isakmp_info_recv_n(iph1, notify, msgid, encrypted)
if (l > 0) { if (l > 0) {
nraw = (char*)notify; nraw = (char*)notify;
nraw += sizeof(*notify) + notify->spi_size; nraw += sizeof(*notify) + notify->spi_size;
ndata = vmalloc(l); if ((ndata = vmalloc(l)) != NULL) {
memcpy(ndata->v, nraw, ndata->l); memcpy(ndata->v, nraw, ndata->l);
plog(LLV_ERROR, LOCATION, iph1->remote, plog(LLV_ERROR, LOCATION, iph1->remote,
"Message: '%s'.\n", "Message: '%s'.\n",
binsanitize(ndata->v, ndata->l)); binsanitize(ndata->v, ndata->l));
vfree(ndata); vfree(ndata);
} else {
plog(LLV_ERROR, LOCATION, iph1->remote,
"Cannot allocate memory\n");
}
} }
} }
return 0; return 0;