[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-tech
Subject: setvbuf.c: fix 32-bit-ism
From: enh <enh () google ! com>
Date: 2022-09-27 19:06:22
Message-ID: CAJgzZoo-BwMvAycCP-1heikQXxgHiTb-6qbFHdJhTqtbGtD_iA () mail ! gmail ! com
[Download RAW message or body]
The existing test is wrong for LP64, where size_t has twice as many
relevant bits as int, not just one. (Found by inspection by
rprichard.)
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c
index 9a08d133f5f..9909dbb8ecd 100644
--- a/lib/libc/stdio/setvbuf.c
+++ b/lib/libc/stdio/setvbuf.c
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*/
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "local.h"
@@ -52,7 +53,7 @@ setvbuf(FILE *fp, char *buf, int mode, size_t size)
* when setting _IONBF.
*/
if (mode != _IONBF)
- if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0)
+ if ((mode != _IOFBF && mode != _IOLBF) || size > INT_MAX)
return (EOF);
/*
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic