summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortedu <>2015-12-10 18:06:06 +0000
committertedu <>2015-12-10 18:06:06 +0000
commitbf8c313f09d518464a5cb48da2ecb091ae7230c4 (patch)
treecaaaf8d0aface3f25e9eac122b65e1dc150ad34e /src
parentf5837f75938b5b80898dbc0757c71c3127b6a2cf (diff)
downloadopenbsd-bf8c313f09d518464a5cb48da2ecb091ae7230c4.tar.gz
openbsd-bf8c313f09d518464a5cb48da2ecb091ae7230c4.tar.bz2
openbsd-bf8c313f09d518464a5cb48da2ecb091ae7230c4.zip
tiny sanity check on file size
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/icdb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/icdb.c b/src/lib/libc/stdlib/icdb.c
index 16d5300ab3..e33a043795 100644
--- a/src/lib/libc/stdlib/icdb.c
+++ b/src/lib/libc/stdlib/icdb.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: icdb.c,v 1.3 2015/11/25 15:49:50 guenther Exp $ */ 1/* $OpenBSD: icdb.c,v 1.4 2015/12/10 18:06:06 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> 3 * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
4 * 4 *
@@ -162,6 +162,8 @@ icdb_open(const char *name, int flags, uint32_t version)
162 return NULL; 162 return NULL;
163 if (fstat(fd, &sb) != 0) 163 if (fstat(fd, &sb) != 0)
164 goto fail; 164 goto fail;
165 if (sb.st_size < sizeof(struct icdbinfo))
166 goto fail;
165 ptr = mmap(NULL, sb.st_size, PROT_READ | 167 ptr = mmap(NULL, sb.st_size, PROT_READ |
166 ((flags & O_RDWR) ? PROT_WRITE : 0), MAP_SHARED, fd, 0); 168 ((flags & O_RDWR) ? PROT_WRITE : 0), MAP_SHARED, fd, 0);
167 if (ptr == MAP_FAILED) 169 if (ptr == MAP_FAILED)