diff options
Diffstat (limited to 'distrib/common/elfrdsetroot.c')
-rw-r--r-- | distrib/common/elfrdsetroot.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/distrib/common/elfrdsetroot.c b/distrib/common/elfrdsetroot.c index 011995843ed..506d984f22f 100644 --- a/distrib/common/elfrdsetroot.c +++ b/distrib/common/elfrdsetroot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elfrdsetroot.c,v 1.11 2006/10/11 20:56:59 deraadt Exp $ */ +/* $OpenBSD: elfrdsetroot.c,v 1.12 2007/08/02 23:10:05 ray Exp $ */ /* $NetBSD: rdsetroot.c,v 1.2 1995/10/13 16:38:39 gwr Exp $ */ /* @@ -38,6 +38,7 @@ #include <sys/types.h> #include <sys/file.h> #include <sys/mman.h> +#include <sys/stat.h> #include <stdio.h> #include <stdlib.h> @@ -168,6 +169,17 @@ main(int argc, char **argv) exit(1); } } else { + struct stat sstat; + + if (fstat(STDIN_FILENO, &sstat) == -1) { + perror("fstat"); + exit(1); + } + if (S_ISREG(sstat.st_mode) && + sstat.st_size > rd_root_size_val) { + fprintf(stderr, "ramdisk too small\n"); + exit(1); + } n = read(STDIN_FILENO, dataseg + rd_root_image_off, rd_root_size_val); if (n < 0) { |