These last two patches remove _DEFAULT_SOURCE and then add
_GNU_SOURCE, but only for one file (tls.c).
The following non-POSIX functions are used by libtls-bearssl:
- strsep (tls_config.c, bearssl.c)
- [v]asprintf (tls.c)
- explicit_bzero (tls_conninfo.c tls_keypair.c compat/freezero.c)
strsep and explicit_bzero originated on BSD, as well as libtls itself,
which is why I had the project-wide _DEFAULT_SOURCE (this is used on
Linux to enable BSD extensions, along with some other stuff).
But, I think the problem you are trying to address is that glibc
doesn't expose [v]asprintf without _GNU_SOURCE (though on all other
libcs I checked, _DEFAULT_SOURCE is sufficient). BSDs ignore
_GNU_SOURCE/_DEFAULT_SOURCE anyway, so I think it makes sense to just
switch to _GNU_SOURCE project-wide.
Could you send a v2 which switches to _GNU_SOURCE rather than removing
_DEFAULT_SOURCE (since that causes a bunch of implicit declarations on
musl)?
Thanks
How about adding this to tls_conninfo.c, tls_keypair.c an
compat/freezero.c:
/* explicit_bzero */
#define _GNU_SOURCE
To tls_config.c and bearssl.c:
/* strsep */
#define _GNU_SOURCE
I find that using global _GNU_SOURCE is a bad idea because you are
forced to add it into all the build system. I prefer to keep the compile
arguments minimal, and compilation units self sufficient.
WDYT?
On 2020-10-16, Issam E. Maghni <issam.e.maghni@mailbox.org> wrote:
> How about adding this to tls_conninfo.c, tls_keypair.c an> compat/freezero.c:> /* explicit_bzero */> #define _GNU_SOURCE>> To tls_config.c and bearssl.c:> /* strsep */> #define _GNU_SOURCE>> I find that using global _GNU_SOURCE is a bad idea because you are> forced to add it into all the build system. I prefer to keep the compile> arguments minimal, and compilation units self sufficient.>> WDYT?
I prefer using a single define here. It is just one additional compile
flag, and not really a big deal to add into a build system.
I went ahead and pushed a commit to switch to _GNU_SOURCE.
Thanks for reporting the issue!