From 5bd4a4806aafc31c67a55c7d8b2993c879dc5bc2 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 7 Sep 2019 22:18:20 +0000 Subject: Remove ::gets for FreeBSD 13 and later Summary: In https://svnweb.freebsd.org/changeset/base/351659 @emaste removed gets() from FreeBSD 13's libc, and our copies of libc++ and libstdc++. In that change, the declarations were simply deleted, but I would like to propose this conditional test instead. Reviewers: EricWF, mclow.lists, emaste Reviewed By: mclow.lists Subscribers: krytarowski, christof, ldionne, emaste, libcxx-commits Differential Revision: https://reviews.llvm.org/D67316 llvm-svn: 371324 --- libcxx/include/__config | 7 +++++++ libcxx/include/cstdio | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'libcxx/include') diff --git a/libcxx/include/__config b/libcxx/include/__config index 03725e28840..f631faa0034 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1152,6 +1152,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_STDOUT #endif +// Some systems do not provide gets() in their C library, for security reasons. +#ifndef _LIBCPP_C_HAS_NO_GETS +# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD__) && __FreeBSD__ >= 13) +# define _LIBCPP_C_HAS_NO_GETS +# endif +#endif + #if defined(__BIONIC__) || defined(__CloudABI__) || \ defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio index 67556938234..0f3f42dac2d 100644 --- a/libcxx/include/cstdio +++ b/libcxx/include/cstdio @@ -152,7 +152,7 @@ using ::tmpnam; #ifndef _LIBCPP_HAS_NO_STDIN using ::getchar; -#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_MSVCRT) +#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS) using ::gets; #endif using ::scanf; -- cgit v1.2.3