diff options
author | 2019-05-02 08:30:10 +0000 | |
---|---|---|
committer | 2019-05-02 08:30:10 +0000 | |
commit | 50054d862bd99fb63ce6a20dfd325b4d5a3f6268 (patch) | |
tree | 5549f9ab3a1b66299753190bf315fbf97890ff00 /lib/libc/stdio/open_memstream.c | |
parent | Fix vmm_support.S compilation error with gcc 8.3 (diff) | |
download | wireguard-openbsd-50054d862bd99fb63ce6a20dfd325b4d5a3f6268.tar.xz wireguard-openbsd-50054d862bd99fb63ce6a20dfd325b4d5a3f6268.zip |
Fix a comparison in open_memstream not to confuse when a negative
value is given for the off. found by nagasaka at IIJ.
ok deraadt
Diffstat (limited to 'lib/libc/stdio/open_memstream.c')
-rw-r--r-- | lib/libc/stdio/open_memstream.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c index 131d4e08e13..6ee5a5c2794 100644 --- a/lib/libc/stdio/open_memstream.c +++ b/lib/libc/stdio/open_memstream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: open_memstream.c,v 1.7 2017/03/17 14:53:08 deraadt Exp $ */ +/* $OpenBSD: open_memstream.c,v 1.8 2019/05/02 08:30:10 yasuoka Exp $ */ /* * Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org> @@ -76,7 +76,7 @@ static fpos_t memstream_seek(void *v, fpos_t off, int whence) { struct state *st = v; - ssize_t base = 0; + size_t base = 0; switch (whence) { case SEEK_SET: @@ -89,7 +89,7 @@ memstream_seek(void *v, fpos_t off, int whence) break; } - if (off > SIZE_MAX - base || off < -base) { + if ((off > 0 && off > SIZE_MAX - base) || (off < 0 && base < -off)) { errno = EOVERFLOW; return (-1); } |