Re: [PATCH] lib/cobalt: only compile __real___open[64]_2 wrappers if fortified

2020-09-11 Thread Jan Kiszka via Xenomai
On 11.09.20 10:32, Jan Leupold via Xenomai wrote:
> If Xenomai itself is not compiled with FORTIFY_SOURCE then the function
> declarations for __open_2() and __open64_2() are not available.
> __STD(__open_2(...)) will not link in this case (would be a very special
> use case anyway?).
> 

That seems like a reasonable approach.

BUT: This must be part of v3 of your patch (version your patches,
please). And there are two more things in that patch which I missed
yesterday. Will comment in the original thread.

Jan

> Signed-off-by: Jan Leupold 
> ---
>  lib/cobalt/wrappers.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
> index 5d86607de..5ff6b63bc 100644
> --- a/lib/cobalt/wrappers.c
> +++ b/lib/cobalt/wrappers.c
> @@ -205,6 +205,7 @@ int __real_open64(const char *path, int oflag, ...)
>  }
>  #endif
>  
> +#if __USE_FORTIFY_LEVEL > 0
>  __weak
>  int __real___open_2(const char *path, int oflag)
>  {
> @@ -216,6 +217,7 @@ int __real___open64_2(const char *path, int oflag)
>  {
>  return __open64_2(path, oflag);
>  }
> +#endif // __USE_FORTIFY_LEVEL > 0
>  
>  __weak
>  int __real_socket(int protocol_family, int socket_type, int protocol)
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux



[PATCH] lib/cobalt: only compile __real___open[64]_2 wrappers if fortified

2020-09-11 Thread Jan Leupold via Xenomai
If Xenomai itself is not compiled with FORTIFY_SOURCE then the function
declarations for __open_2() and __open64_2() are not available.
__STD(__open_2(...)) will not link in this case (would be a very special
use case anyway?).

Signed-off-by: Jan Leupold 
---
 lib/cobalt/wrappers.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 5d86607de..5ff6b63bc 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -205,6 +205,7 @@ int __real_open64(const char *path, int oflag, ...)
 }
 #endif
 
+#if __USE_FORTIFY_LEVEL > 0
 __weak
 int __real___open_2(const char *path, int oflag)
 {
@@ -216,6 +217,7 @@ int __real___open64_2(const char *path, int oflag)
 {
 return __open64_2(path, oflag);
 }
+#endif // __USE_FORTIFY_LEVEL > 0
 
 __weak
 int __real_socket(int protocol_family, int socket_type, int protocol)
-- 
2.20.1


-- 
_
R-S-I Elektrotechnik GmbH & Co. KG
Woelkestrasse 11
D-85301 Schweitenkirchen
Fon: +49 8444 9204-0
Fax: +49 8444 9204-50
www.rsi-elektrotechnik.de

_
Amtsgericht Ingolstadt - GmbH: HRB 191328 - KG: HRA 170363
Geschäftsführer: Dr.-Ing. Michael Sorg, Dipl.-Ing. Franz Sorg
USt-IdNr.: DE 128592548