commit ca2df4878c2539c6a66553df182758a01ebcdcb8
parent 8d090c8a1a86408fa8b54029b97fccd17f9d35d5
Author: q66 <q66@chimera-linux.org>
Date: Fri, 15 Dec 2023 23:09:31 +0100
Move wctomb to stdlib.h and disable it for now
Diffstat:
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/include/stdlib.h b/include/stdlib.h
@@ -59,6 +59,24 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s,
return __orig_wcstombs(__s, __ws, __n);
}
+#if 0
+/* https://github.com/jvoisin/fortify-headers/issues/24 */
+#ifdef MB_CUR_MAX
+#undef wctomb
+#if __has_builtin(__builtin_wctomb)
+__diagnose_as_builtin(__builtin_wctomb, 1, 2)
+#endif
+_FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
+{
+ __fh_size_t __b = __bos(__s, 0);
+
+ if (__s && 16 > __b && MB_CUR_MAX > __b)
+ __builtin_trap();
+ return __orig_wctomb(__s, __w);
+}
+#endif // MB_CUR_MAX
+#endif
+
#undef qsort
#if __has_builtin(__builtin_qsort)
__diagnose_as_builtin(__builtin_qsort, 1, 2, 3, 4)
diff --git a/include/wchar.h b/include/wchar.h
@@ -224,21 +224,6 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d,
return __r;
}
-#ifdef MB_CUR_MAX
-#undef wctomb
-#if __has_builtin(__builtin_wctomb)
-__diagnose_as_builtin(__builtin_wctomb, 1, 2)
-#endif
-_FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
-{
- __fh_size_t __b = __bos(__s, 0);
-
- if (__s && 16 > __b && MB_CUR_MAX > __b)
- __builtin_trap();
- return __orig_wctomb(__s, __w);
-}
-#endif // MB_CUR_MAX
-
#if __has_builtin(__builtin_wmemcpy)
__diagnose_as_builtin(__builtin_wmemcpy, 1, 2, 3)
#endif