summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/icdb.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-12-10 18:06:06 +0000
committertedu <tedu@openbsd.org>2015-12-10 18:06:06 +0000
commitfebce5fc05165f40665c1c55353ecf49583bf253 (patch)
tree517225d583e852afad5162be573ecc2361aa60e1 /lib/libc/stdlib/icdb.c
parentminor changes, mostly whitespace, from unbound 1.5.7 (diff)
downloadwireguard-openbsd-febce5fc05165f40665c1c55353ecf49583bf253.tar.xz
wireguard-openbsd-febce5fc05165f40665c1c55353ecf49583bf253.zip
tiny sanity check on file size
Diffstat (limited to 'lib/libc/stdlib/icdb.c')
-rw-r--r--lib/libc/stdlib/icdb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/stdlib/icdb.c b/lib/libc/stdlib/icdb.c
index 16d5300ab3d..e33a043795f 100644
--- a/lib/libc/stdlib/icdb.c
+++ b/lib/libc/stdlib/icdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icdb.c,v 1.3 2015/11/25 15:49:50 guenther Exp $ */
+/* $OpenBSD: icdb.c,v 1.4 2015/12/10 18:06:06 tedu Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
@@ -162,6 +162,8 @@ icdb_open(const char *name, int flags, uint32_t version)
return NULL;
if (fstat(fd, &sb) != 0)
goto fail;
+ if (sb.st_size < sizeof(struct icdbinfo))
+ goto fail;
ptr = mmap(NULL, sb.st_size, PROT_READ |
((flags & O_RDWR) ? PROT_WRITE : 0), MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED)