During testing of _FORTIFY_SOURCE on current MSYS2, I found that __gets_chk() is no longer provided. The *_chk() Functions from libssp.a were apparently moved to libmingwex.a, but without __gets_chk().

Is this possibly because the FILE types of UCRT and MSVCRT differ?

If this change was intentional, I would suggest to apply this patch.

Upstream still provides this function:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libssp/gets-chk.c

--
Regards,
Christian

From 8d0ef5463e1695a40aeaef948787a648a496f267 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Sun, 12 Feb 2023 16:05:07 +0100
Subject: [PATCH] headers: _FORTIFY_SOURCE: Remove usage of __gets_chk() for
 gets()

This function is no longer provided by recent libraries.
---
 mingw-w64-headers/crt/stdio.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index 5042409a2..ccc4ac9c9 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -783,7 +783,6 @@ int vsnprintf (char *__stream, size_t __n, const char 
*__format, __builtin_va_li
 
 #if __MINGW_FORTIFY_LEVEL > 0
 
-char * __cdecl __gets_chk(char *, size_t);
 char * __cdecl __mingw_call_gets_warn(char *) __MINGW_ASM_CALL(gets)
   __attribute__((__warning__("Using gets() is always unsafe - use fgets() 
instead")));
 char * __cdecl __mingw_call_fgets(char * __restrict__, int, FILE * 
__restrict__) __MINGW_ASM_CALL(fgets);
@@ -793,8 +792,6 @@ char * __cdecl __mingw_call_tmpnam(char *) 
__MINGW_ASM_CALL(tmpnam);
 __mingw_bos_extern_ovr
 char * gets(char * __dst)
 {
-  if (__mingw_bos_known(__dst))
-    return __gets_chk(__dst, __mingw_bos(__dst, 1));
   return __mingw_call_gets_warn(__dst);
 }
 
-- 
2.38.1

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to