Browse Source

tiny sanity check on file size

OPENBSD_5_9
tedu 9 years ago
parent
commit
acb3665fb0
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      src/lib/libc/stdlib/icdb.c

+ 3
- 1
src/lib/libc/stdlib/icdb.c View File

@ -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> * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
* *
@ -162,6 +162,8 @@ icdb_open(const char *name, int flags, uint32_t version)
return NULL; return NULL;
if (fstat(fd, &sb) != 0) if (fstat(fd, &sb) != 0)
goto fail; goto fail;
if (sb.st_size < sizeof(struct icdbinfo))
goto fail;
ptr = mmap(NULL, sb.st_size, PROT_READ | ptr = mmap(NULL, sb.st_size, PROT_READ |
((flags & O_RDWR) ? PROT_WRITE : 0), MAP_SHARED, fd, 0); ((flags & O_RDWR) ? PROT_WRITE : 0), MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) if (ptr == MAP_FAILED)


Loading…
Cancel
Save