mirror of
https://github.com/opnsense/src.git
synced 2026-04-20 21:59:20 -04:00
libc: Fix size range check in setvbuf
From enh at google.com via openbsd-tech mailing list via pfg@: 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.)
This commit is contained in:
parent
89e5ef8917
commit
9515313b26
1 changed files with 2 additions and 1 deletions
|
|
@ -39,6 +39,7 @@ static char sccsid[] = "@(#)setvbuf.c 8.2 (Berkeley) 11/16/93";
|
|||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "un-namespace.h"
|
||||
|
|
@ -62,7 +63,7 @@ setvbuf(FILE * __restrict fp, char * __restrict 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);
|
||||
|
||||
FLOCKFILE_CANCELSAFE(fp);
|
||||
|
|
|
|||
Loading…
Reference in a new issue