Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 5 Mar 2019 22:05:17 +0100
From: Sebastian Kemper <sebastian_ml@....net>
To: musl@...ts.openwall.com
Subject: Re: Asterisk 16 function redefines

On Tue, Mar 05, 2019 at 09:05:30PM +0100, Markus Wichmann wrote:
> On Tue, Mar 05, 2019 at 08:28:50PM +0100, Sebastian Kemper wrote:
> > #define calloc(nmemb, size) \
> > 	__ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > #define malloc(size) \
> > 	__ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > #define free(ptr) \
> > 	__ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
> > 
> > Compile output example:
> > 
> > /home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/sched.h:76:28: error: expected declaration specifiers or '...' before string constant
> >  void *calloc(size_t, size_t);
> >                             ^
> 
> Welcome to the wonderful world of the preprocessor. The define above is
> in effect here, so the compiler never sees the valid function prototype,
> the compiler sees
> 
> void *__ast_repl_calloc(size_t, size_t, "sched.h", 76, "");
> 
> And can't deal with that. Maybe they should include the replacements as
> the very last thing.

Hello Markus,

It is indeed wonderful ;-)

What wonders me the most is that the same preprocessor define works fine
with the same compiler using a different libc. I tried

gcc 7.4.0 + musl 1.1.20:	NOK
gcc 7.1.1 + uclibc 1.0.31:	OK
gcc 8.2.0 + glibc 2.27:		OK

Different gcc versions, but still.

Just read Szabolcs reply. Now it makes a bit more sense to me.

> > Regarding ASTMM_BLOCK: redefines libc functions to cause compile errors. [...]
> 
> And they cause compile errors. Mission accomplished.

I don't think exactly that failure is what they had in mind :D

Thanks!
Seb

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.