From: Mark Andrews Date: Fri, 18 Sep 2015 21:12:02 +0000 (+1000) Subject: 4218. [bug] Potential null pointer dereference on out of memory ... X-Git-Tag: v9.11.0a1~455 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4dd41c7d5976ff6889e4fbf306036f4256af409a;p=thirdparty%2Fbind9.git 4218. [bug] Potential null pointer dereference on out of memory if mmap is not supported. [RT #40777] --- diff --git a/CHANGES b/CHANGES index fe6ffffa237..8aa2dcba1ab 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +4218. [bug] Potential null pointer dereference on out of memory if mmap is not supported. [RT #40777] + 4217. [protocol] Add support for CSYNC. [RT #40532] 4216. [cleanup] Silence static analysis warnings. [RT #40649] diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 5e671d5b179..3a76e0833c3 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -678,6 +678,9 @@ isc_file_mmap(void *addr, size_t len, int prot, len = end - offset; buf = malloc(len); + if (buf == NULL) + return (NULL); + ret = read(fd, buf, len); if (ret != (ssize_t) len) { free(buf); diff --git a/lib/isc/win32/file.c b/lib/isc/win32/file.c index ba481228adc..99e52d2e964 100644 --- a/lib/isc/win32/file.c +++ b/lib/isc/win32/file.c @@ -757,6 +757,9 @@ isc_file_mmap(void *addr, size_t len, int prot, len = end - offset; buf = malloc(len); + if (buf == NULL) + return (NULL); + ret = read(fd, buf, (unsigned int) len); if (ret != (ssize_t) len) { free(buf);