From 1f53f6f82f2165e421d94a83a731c1308097849f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 3 Mar 2005 16:52:27 +0000 Subject: 2.3.4-11 --- libio/bits/stdio2.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'libio') diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index e33cbb401a..6ab6841c53 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -88,13 +88,17 @@ extern char *__gets_chk (char *__str, size_t); ((__bos (__str) == (size_t) -1) \ ? gets (__str) : __gets_chk (__str, __bos (__str))) -extern char *__fgets_chk (char *s, size_t size, int n, FILE *stream); +extern void __chk_fail (void) __attribute__((noreturn)); #define fgets(__str, __n, __fp) \ - ((__bos (__str) == (size_t) -1) \ - ? fgets (__str, __n, __fp) : __fgets_chk (__str, __bos (__str), __n, __fp)) + (__extension__ \ + ({ size_t __n_val = (__n); \ + if (__bos (__str) != (size_t) -1 && __bos (__str) < __n_val) \ + __chk_fail (); \ + fgets (__str, __n_val, __fp); })) -extern char *__fgets_unlocked_chk (char *s, size_t size, int n, FILE *stream); #define fgets_unlocked(__str, __n, __fp) \ - ((__bos (__str) == (size_t) -1) \ - ? fgets_unlocked (__str, __n, __fp) \ - : __fgets_unlocked_chk (__str, __bos (__str), __n, __fp)) + (__extension__ \ + ({ size_t __n_val = (__n); \ + if (__bos (__str) != (size_t) -1 && __bos (__str) < __n_val) \ + __chk_fail (); \ + fgets_unlocked (__str, __n_val, __fp); })) -- cgit v1.2.3