mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-20 03:47:16 +02:00
To many issues, and it blocks us. Lets revert it again til issues are fixed upstream. This reverts commit27c6143971
. This reverts commiteb4c10b9c6
. This reverts commit0920eac441
. This reverts commitbd6dc56ca9
. This reverts commit52fd5614b7
.
762 lines
28 KiB
Diff
762 lines
28 KiB
Diff
From 1d39f5599ebeb572ac16c3b2e8ad4691463bf6a1 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Kolesa <daniel@octaforge.org>
|
|
Date: Wed, 26 Oct 2022 00:30:00 +0200
|
|
Subject: [PATCH] add initial clang support
|
|
|
|
---
|
|
include/fortify-headers.h | 25 ++++++++++++++++++--
|
|
include/poll.h | 7 +++---
|
|
include/stdio.h | 38 +++++++++++++++++++++++------
|
|
include/stdlib.h | 4 +++-
|
|
include/string.h | 33 ++++++++++++++++----------
|
|
include/strings.h | 6 +++--
|
|
include/sys/select.h | 13 ++++++++--
|
|
include/sys/socket.h | 13 ++++++----
|
|
include/unistd.h | 30 +++++++++++++----------
|
|
include/wchar.h | 50 ++++++++++++++++++++++++++-------------
|
|
10 files changed, 158 insertions(+), 61 deletions(-)
|
|
|
|
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
|
|
index 4de5bef..2cf3697 100644
|
|
--- a/include/fortify-headers.h
|
|
+++ b/include/fortify-headers.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -16,9 +17,29 @@
|
|
#ifndef _FORTIFY_HEADERS_H
|
|
#define _FORTIFY_HEADERS_H
|
|
|
|
+#ifdef __clang__
|
|
+
|
|
+/* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */
|
|
+#define _FORTIFY_POSN(n) const __attribute__((__pass_object_size__(n)))
|
|
+/* we can't use extern inline with overloads without making them external */
|
|
+#define _FORTIFY_INLINE static __inline__ \
|
|
+ __attribute__((__always_inline__,__artificial__,__overloadable__))
|
|
+
|
|
+#else /* !__clang__ */
|
|
+
|
|
+#define _FORTIFY_POSN(n)
|
|
+#define _FORTIFY_INLINE extern __inline__ \
|
|
+ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
|
+
|
|
+#endif /* __clang__ */
|
|
+
|
|
+#define _FORTIFY_POS0 _FORTIFY_POSN(0)
|
|
+#define _FORTIFY_POS1 _FORTIFY_POSN(1)
|
|
+#define _FORTIFY_POS2 _FORTIFY_POSN(2)
|
|
+
|
|
#define _FORTIFY_STR(s) #s
|
|
#define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn)
|
|
-#define _FORTIFY_FN(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn); \
|
|
- extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
|
+#define _FORTIFY_FNB(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn)
|
|
+#define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE
|
|
|
|
#endif
|
|
diff --git a/include/poll.h b/include/poll.h
|
|
index 24691f1..60a7623 100644
|
|
--- a/include/poll.h
|
|
+++ b/include/poll.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -30,7 +31,7 @@ extern "C" {
|
|
|
|
#undef poll
|
|
|
|
-_FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
|
|
+_FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s)
|
|
{
|
|
__typeof__(sizeof 0) __b = __builtin_object_size(__f, 0);
|
|
|
|
@@ -41,8 +42,8 @@ _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
|
|
|
|
#ifdef _GNU_SOURCE
|
|
#undef ppoll
|
|
-_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s,
|
|
- const sigset_t *__m)
|
|
+_FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n,
|
|
+ const struct timespec *__s, const sigset_t *__m)
|
|
{
|
|
__typeof__(sizeof 0) __b = __builtin_object_size(__f, 0);
|
|
|
|
diff --git a/include/stdio.h b/include/stdio.h
|
|
index a965184..e50f65f 100644
|
|
--- a/include/stdio.h
|
|
+++ b/include/stdio.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -36,7 +37,7 @@ extern "C" {
|
|
#undef snprintf
|
|
#undef sprintf
|
|
|
|
-_FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f)
|
|
+_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -45,7 +46,8 @@ _FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f)
|
|
return __orig_fgets(__s, __n, __f);
|
|
}
|
|
|
|
-_FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f)
|
|
+_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
|
|
+ size_t __m, FILE *__f)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -56,7 +58,8 @@ _FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f)
|
|
return __orig_fread(__d, __n, __m, __f);
|
|
}
|
|
|
|
-_FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE *__f)
|
|
+_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
|
|
+ size_t __m, FILE *__f)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -67,8 +70,8 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE
|
|
return __orig_fwrite(__d, __n, __m, __f);
|
|
}
|
|
|
|
-_FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
|
|
- __builtin_va_list __v)
|
|
+_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
|
|
+ const char *__f, __builtin_va_list __v)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -77,7 +80,8 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
|
|
return __orig_vsnprintf(__s, __n, __f, __v);
|
|
}
|
|
|
|
-_FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list __v)
|
|
+_FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
|
|
+ __builtin_va_list __v)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
int __r;
|
|
@@ -92,9 +96,26 @@ _FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list
|
|
return __r;
|
|
}
|
|
|
|
-_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...)
|
|
+#if defined(__has_builtin)
|
|
+#if __has_builtin(__builtin_va_arg_pack)
|
|
+
|
|
+/* clang is missing __builtin_va_arg_pack, so we cannot use these impls
|
|
+ * outside of gcc; we then have a few options:
|
|
+ *
|
|
+ * 1) using va_start/end and implementing these functions as static inline,
|
|
+ * with inlining never happening; that means extra symbols with internal
|
|
+ * linkage, which is not ideal
|
|
+ * 2) using macros; this is incompatible with c++ and since musl does not
|
|
+ * have the __chk variants, we'd need to implement a body with intermediate
|
|
+ * variables within the macro, which means more non-portable mess
|
|
+ * 3) not implementing these under clang, which is what we do for now
|
|
+ */
|
|
+
|
|
+_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
|
|
+ const char *__f, ...)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
+ int __r;
|
|
|
|
if (__n > __b)
|
|
__builtin_trap();
|
|
@@ -116,6 +137,9 @@ _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
|
|
return __r;
|
|
}
|
|
|
|
+#endif /* __has_builtin(__builtin_va_arg_pack) */
|
|
+#endif /* defined(__has_builtin) */
|
|
+
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
diff --git a/include/stdlib.h b/include/stdlib.h
|
|
index 11155cf..2b854d0 100644
|
|
--- a/include/stdlib.h
|
|
+++ b/include/stdlib.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -35,7 +36,8 @@ __extension__
|
|
extern "C" {
|
|
#endif
|
|
|
|
-#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
+/* FIXME clang */
|
|
+#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__)
|
|
#undef realpath
|
|
_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
|
|
{
|
|
diff --git a/include/string.h b/include/string.h
|
|
index 66c23e1..9d4658c 100644
|
|
--- a/include/string.h
|
|
+++ b/include/string.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -36,7 +37,8 @@ extern "C" {
|
|
#undef strncat
|
|
#undef strncpy
|
|
|
|
-_FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
|
|
+_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
|
|
+ const void * _FORTIFY_POS0 __os, size_t __n)
|
|
{
|
|
size_t __bd = __builtin_object_size(__od, 0);
|
|
size_t __bs = __builtin_object_size(__os, 0);
|
|
@@ -53,7 +55,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
|
|
return __builtin_memcpy(__od, __os, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
|
|
+_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
|
|
+ const void * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __bd = __builtin_object_size(__d, 0);
|
|
size_t __bs = __builtin_object_size(__s, 0);
|
|
@@ -63,7 +66,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
|
|
return __orig_memmove(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
|
|
+_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -76,7 +79,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
|
|| defined(_BSD_SOURCE)
|
|
#undef stpcpy
|
|
-_FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
|
|
+_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -86,7 +89,8 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
|
|
}
|
|
|
|
#undef stpncpy
|
|
-_FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n)
|
|
+_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
|
|
+ size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -96,7 +100,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n)
|
|
}
|
|
#endif
|
|
|
|
-_FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
|
|
+_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -105,7 +109,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
|
|
return __orig_strcat(__d, __s);
|
|
}
|
|
|
|
-_FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
|
|
+_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -114,7 +118,8 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
|
|
return __orig_strcpy(__d, __s);
|
|
}
|
|
|
|
-_FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
|
|
+_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
|
|
+ size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
size_t __sl, __dl;
|
|
@@ -130,7 +135,8 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
|
|
return __orig_strncat(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n)
|
|
+_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
|
|
+ const char *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -141,7 +147,8 @@ _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n)
|
|
|
|
#ifdef _GNU_SOURCE
|
|
#undef mempcpy
|
|
-_FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
|
|
+_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d,
|
|
+ const void * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __bd = __builtin_object_size(__d, 0);
|
|
size_t __bs = __builtin_object_size(__s, 0);
|
|
@@ -155,7 +162,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
#undef strlcat
|
|
#undef strlcpy
|
|
-_FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
|
|
+_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d,
|
|
+ const char *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -164,7 +172,8 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
|
|
return __orig_strlcat(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n)
|
|
+_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d,
|
|
+ const char *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
diff --git a/include/strings.h b/include/strings.h
|
|
index a16e1ad..4c7e1c7 100644
|
|
--- a/include/strings.h
|
|
+++ b/include/strings.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -30,7 +31,8 @@ extern "C" {
|
|
|| (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
|
|
#undef bcopy
|
|
#undef bzero
|
|
-_FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n)
|
|
+_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
|
|
+ void * _FORTIFY_POS0 __d, size_t __n)
|
|
{
|
|
size_t __bd = __builtin_object_size(__d, 0);
|
|
size_t __bs = __builtin_object_size(__s, 0);
|
|
@@ -40,7 +42,7 @@ _FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n)
|
|
return __orig_bcopy(__s, __d, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(bzero) void bzero(void *__s, size_t __n)
|
|
+_FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
diff --git a/include/sys/select.h b/include/sys/select.h
|
|
index bcee8be..527d8e4 100644
|
|
--- a/include/sys/select.h
|
|
+++ b/include/sys/select.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -27,8 +28,14 @@ __extension__
|
|
extern "C" {
|
|
#endif
|
|
|
|
+#ifdef __clang__
|
|
+#define _FORTIFY_FD_POS0 const __attribute__((__pass_object_size__(0)))
|
|
+#else
|
|
+#define _FORTIFY_FD_POS0
|
|
+#endif
|
|
+
|
|
static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
|
-void __fortify_FD_CLR(int __f, fd_set *__s)
|
|
+void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -38,7 +45,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s)
|
|
}
|
|
|
|
static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
|
|
-void __fortify_FD_SET(int __f, fd_set *__s)
|
|
+void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -47,6 +54,8 @@ void __fortify_FD_SET(int __f, fd_set *__s)
|
|
FD_SET(__f, __s);
|
|
}
|
|
|
|
+#undef _FORTIFY_FD_POS0
|
|
+
|
|
#undef FD_CLR
|
|
#define FD_CLR(fd, set) __fortify_FD_CLR(fd, set)
|
|
#undef FD_SET
|
|
diff --git a/include/sys/socket.h b/include/sys/socket.h
|
|
index ad6ab2d..02cad5f 100644
|
|
--- a/include/sys/socket.h
|
|
+++ b/include/sys/socket.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -33,7 +34,8 @@ extern "C" {
|
|
#undef send
|
|
#undef sendto
|
|
|
|
-_FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl)
|
|
+_FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n,
|
|
+ int __fl)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -42,7 +44,8 @@ _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl)
|
|
return __orig_recv(__f, __s, __n, __fl);
|
|
}
|
|
|
|
-_FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl,
|
|
+_FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void * _FORTIFY_POS0 __s,
|
|
+ size_t __n, int __fl,
|
|
struct sockaddr *__a, socklen_t *__l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
@@ -52,7 +55,8 @@ _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl,
|
|
return __orig_recvfrom(__f, __s, __n, __fl, __a, __l);
|
|
}
|
|
|
|
-_FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl)
|
|
+_FORTIFY_FN(send) ssize_t send(int __f, const void * _FORTIFY_POS0 __s,
|
|
+ size_t __n, int __fl)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -61,7 +65,8 @@ _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl)
|
|
return __orig_send(__f, __s, __n, __fl);
|
|
}
|
|
|
|
-_FORTIFY_FN(sendto) ssize_t sendto(int __f, const void *__s, size_t __n, int __fl,
|
|
+_FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s,
|
|
+ size_t __n, int __fl,
|
|
const struct sockaddr *__a, socklen_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
diff --git a/include/unistd.h b/include/unistd.h
|
|
index 09980ba..9f8a187 100644
|
|
--- a/include/unistd.h
|
|
+++ b/include/unistd.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -40,7 +41,7 @@ extern "C" {
|
|
#undef ttyname_r
|
|
#undef write
|
|
|
|
-_FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l)
|
|
+_FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b);
|
|
@@ -50,7 +51,7 @@ _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l)
|
|
return __r;
|
|
}
|
|
|
|
-_FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l)
|
|
+_FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -61,7 +62,7 @@ _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l)
|
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
#undef getdomainname
|
|
-_FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l)
|
|
+_FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -71,7 +72,7 @@ _FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l)
|
|
}
|
|
#endif
|
|
|
|
-_FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s)
|
|
+_FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -80,7 +81,7 @@ _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s)
|
|
return __orig_getgroups(__l, __s);
|
|
}
|
|
|
|
-_FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l)
|
|
+_FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -89,7 +90,7 @@ _FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l)
|
|
return __orig_gethostname(__s, __l);
|
|
}
|
|
|
|
-_FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l)
|
|
+_FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -98,7 +99,8 @@ _FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l)
|
|
return __orig_getlogin_r(__s, __l);
|
|
}
|
|
|
|
-_FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o)
|
|
+_FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s,
|
|
+ size_t __n, off_t __o)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -107,7 +109,7 @@ _FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o)
|
|
return __orig_pread(__f, __s, __n, __o);
|
|
}
|
|
|
|
-_FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n)
|
|
+_FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -116,7 +118,8 @@ _FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n)
|
|
return __orig_read(__f, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n)
|
|
+_FORTIFY_FN(readlink) ssize_t readlink(const char *__p,
|
|
+ char * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -125,7 +128,8 @@ _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n)
|
|
return __orig_readlink(__p, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s, size_t __n)
|
|
+_FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p,
|
|
+ char * _FORTIFY_POS0 __s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -134,7 +138,8 @@ _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s,
|
|
return __orig_readlinkat(__f, __p, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n)
|
|
+_FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s,
|
|
+ size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -143,7 +148,8 @@ _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n)
|
|
return __orig_ttyname_r(__f, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(write) ssize_t write(int __f, const void *__s, size_t __n)
|
|
+_FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
|
|
+ size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
diff --git a/include/wchar.h b/include/wchar.h
|
|
index c5d0e5d..41423a8 100644
|
|
--- a/include/wchar.h
|
|
+++ b/include/wchar.h
|
|
@@ -1,5 +1,6 @@
|
|
/*
|
|
* Copyright (C) 2015-2017 Dimitris Papastamos <sin@2f30.org>
|
|
+ * Copyright (C) 2022 q66 <q66@chimera-linux.org>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted.
|
|
@@ -55,7 +56,8 @@ extern "C" {
|
|
#undef wmemmove
|
|
#undef wmemset
|
|
|
|
-_FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f)
|
|
+_FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s,
|
|
+ int __n, FILE *__f)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -67,7 +69,8 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f)
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
#undef mbsnrtowcs
|
|
-_FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t __n,
|
|
+_FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const char **__s, size_t __n,
|
|
size_t __wn, mbstate_t *__st)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
@@ -87,7 +90,8 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t
|
|
}
|
|
#endif
|
|
|
|
-_FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t __wn,
|
|
+_FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const char **__s, size_t __wn,
|
|
mbstate_t *__st)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
@@ -100,7 +104,8 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t _
|
|
return __r;
|
|
}
|
|
|
|
-_FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __wn)
|
|
+_FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws,
|
|
+ const char *__s, size_t __wn)
|
|
{
|
|
size_t __b = __builtin_object_size(__ws, 0);
|
|
|
|
@@ -109,7 +114,9 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __w
|
|
return __orig_mbstowcs(__ws, __s, __wn);
|
|
}
|
|
|
|
-_FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st)
|
|
+/* FIXME clang */
|
|
+#ifndef __clang__
|
|
+_FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st)
|
|
{
|
|
if (__s && MB_LEN_MAX > __builtin_object_size(__s, 2)) {
|
|
char __buf[MB_LEN_MAX];
|
|
@@ -125,8 +132,10 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st)
|
|
}
|
|
return __orig_wcrtomb(__s, __w, __st);
|
|
}
|
|
+#endif
|
|
|
|
-_FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s)
|
|
+_FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -135,7 +144,8 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s)
|
|
return __orig_wcscat(__d, __s);
|
|
}
|
|
|
|
-_FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s)
|
|
+_FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -144,7 +154,8 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s)
|
|
return __orig_wcscpy(__d, __s);
|
|
}
|
|
|
|
-_FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t __n)
|
|
+_FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
size_t __sl, __dl;
|
|
@@ -160,7 +171,8 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t _
|
|
return __orig_wcsncat(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t __n)
|
|
+_FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -172,7 +184,8 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t _
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
#undef wcsnrtombs
|
|
-_FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t __wn,
|
|
+_FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d,
|
|
+ const wchar_t **__s, size_t __wn,
|
|
size_t __n, mbstate_t *__st)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
@@ -192,7 +205,8 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t
|
|
}
|
|
#endif
|
|
|
|
-_FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t __n,
|
|
+_FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d,
|
|
+ const wchar_t **__s, size_t __n,
|
|
mbstate_t *__st)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
@@ -204,7 +218,8 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t _
|
|
return __r;
|
|
}
|
|
|
|
-_FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n)
|
|
+_FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s,
|
|
+ const wchar_t *__ws, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -213,7 +228,7 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n
|
|
return __orig_wcstombs(__s, __ws, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w)
|
|
+_FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|
|
@@ -222,7 +237,8 @@ _FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w)
|
|
return __orig_wctomb(__s, __w);
|
|
}
|
|
|
|
-_FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t __n)
|
|
+_FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -231,7 +247,8 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t _
|
|
return __orig_wmemcpy(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t __n)
|
|
+_FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d,
|
|
+ const wchar_t *__s, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__d, 0);
|
|
|
|
@@ -240,7 +257,8 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t
|
|
return __orig_wmemmove(__d, __s, __n);
|
|
}
|
|
|
|
-_FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t *__s, wchar_t __c, size_t __n)
|
|
+_FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s,
|
|
+ wchar_t __c, size_t __n)
|
|
{
|
|
size_t __b = __builtin_object_size(__s, 0);
|
|
|