This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo


* Paul Eggert:

> On 5/23/19 2:34 AM, Florian Weimer wrote:
>> +# ifdef __GNUC__
>> +  /* This avoids an unwanted array subscript check by the compiler,
>> +     while preserving the size of the type.  */
>> +  __extension__ union
>> +  {
>> +    Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements.  */
>> +    Dl_serpath __dls_serpath_pad[1];
>> +  };
>> +# else /* !__GNUC__ */
>>     Dl_serpath dls_serpath[1];	/* Actually longer, dls_cnt elements.  */
>> +# endif /* !__GNUC__ */
>
> Since this is actually a flexible array member, shouldn't we be using
> C99's support for that if available, instead? Something like the
> attached untested patch, say. We've been using a FLEXIBLE_ARRAY_MEMBER
> macro in Gnulib for quite some time to do this sort of thing.

This changes the size of the type and is not source-code-compatible.  I
have not investigated whether the change is still reasonably safe, but
usually, wo do not make such changes.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]