From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo
Date: Tue, 18 Jun 2019 16:27:05 +0200 [thread overview]
Message-ID: <87imt37yva.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <87a7ey8ytd.fsf@oldenburg2.str.redhat.com> (Florian Weimer's message of "Mon, 03 Jun 2019 17:37:34 +0200")
* Florian Weimer:
> The dls_serpath path field, as an array of length 1, introduces
> unexpected array subscript checks with some compilers.
>
> GCC versions before 3.0 treat the nested anonymous union as a
> declaration of an unnamed type, and not as a member declaration,
> so this construct cannot be used for these compilers.
>
> 2019-06-03 Florian Weimer <fweimer@redhat.com>
>
> [BZ #24166]
> * dlfcn/dlfcn.h (Dl_serinfo): Do not use array of length 1 for
> dls_serpath field.
>
> diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h
> index 896ad6fc9b..c550371999 100644
> --- a/dlfcn/dlfcn.h
> +++ b/dlfcn/dlfcn.h
> @@ -180,7 +180,19 @@ typedef struct
> {
> size_t dls_size; /* Size in bytes of the whole buffer. */
> unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */
> +# if __GNUC_PREREQ (3, 0)
> + /* The zero-length array avoids an unwanted array subscript check by
> + the compiler, while the surrounding anonymous union preserves the
> + historic size of the type. At the time of writing, GNU C does
> + not support structs with flexible array members in unions. */
> + __extension__ union
> + {
> + Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements. */
> + Dl_serpath __dls_serpath_pad[1];
> + };
> +# else
> Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */
> +# endif
> } Dl_serinfo;
> #endif /* __USE_GNU */
>
Ping?
Thanks,
Florian
next prev parent reply other threads:[~2019-06-18 14:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 15:37 [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo Florian Weimer
2019-06-18 14:27 ` Florian Weimer [this message]
2019-06-18 22:17 ` Paul Eggert
-- strict thread matches above, loose matches on Subject: below --
2019-05-23 9:34 Florian Weimer
2019-05-23 22:42 ` Paul Eggert
2019-05-23 22:50 ` Joseph Myers
2019-05-24 8:42 ` Florian Weimer
2019-05-24 23:47 ` Paul Eggert
2019-05-27 19:04 ` Florian Weimer
2019-06-01 8:48 ` Paul Eggert
2019-06-03 7:59 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imt37yva.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).