fix broken overflow test.
This commit is contained in:
parent
067a8b527b
commit
c37383f14b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: look.c,v 1.13 2009/04/12 14:01:20 lukem Exp $ */
|
||||
/* $NetBSD: look.c,v 1.14 2009/04/26 15:55:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)look.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
__RCSID("$NetBSD: look.c,v 1.13 2009/04/12 14:01:20 lukem Exp $");
|
||||
__RCSID("$NetBSD: look.c,v 1.14 2009/04/26 15:55:50 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -103,6 +103,7 @@ main(argc, argv)
|
|||
int ch, fd, termchar;
|
||||
char *back, *front, *string, *p;
|
||||
const char *file;
|
||||
size_t len;
|
||||
|
||||
string = NULL;
|
||||
file = _PATH_WORDS;
|
||||
|
@ -143,12 +144,15 @@ main(argc, argv)
|
|||
|
||||
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
|
||||
err(2, "%s", file);
|
||||
if (sb.st_size > (off_t)SIZE_T_MAX)
|
||||
err(2, "%s: %s", file, strerror(EFBIG));
|
||||
if ((front = mmap(NULL, (size_t)sb.st_size,
|
||||
len = (size_t)sb.st_size;
|
||||
if ((off_t)len != sb.st_size) {
|
||||
errno = EFBIG;
|
||||
err(2, "%s", file);
|
||||
}
|
||||
if ((front = mmap(NULL, len,
|
||||
PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0)) == NULL)
|
||||
err(2, "%s", file);
|
||||
back = front + sb.st_size;
|
||||
back = front + len;
|
||||
exit(look(string, front, back));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue