[PATCH v2] tftp.h: rework layout to work with fortification
Mike Frysinger
vapier@gentoo.org
Sat Apr 28 03:49:00 GMT 2012
On Tuesday 17 April 2012 23:27:26 Mike Frysinger wrote:
> On Thursday 12 April 2012 13:30:38 Mike Frysinger wrote:
> > The current tftp structure does not work when fortification is enabled.
> > Starting with gcc-4.5, more size checking was added to trigger these.
> > Older versions just didn't have enough information, so they returned -1
> > as the sizes.
> >
> > First, the tu_stuff field is declared as 1 byte (when it's really an
> > arbitrary length C string), so attempting to strcpy() with it results
> > in crashes. This fails with _FORTIFY_SOURCE=1.
> >
> > Second, even if we change that to [0] (since gcc does not allow flexible
> > array members in an union), gcc is not smart enough to see that they are
> > two overlapping flexible arrays (tu_stuff and tu_data), so it will still
> > trigger an abort with _FORTIFY_SOURCE=2. This is because it thinks that
> > tu_stuff is 0 bytes and tu_data comes after it.
> >
> > Talking to upstream gcc, they don't seem terribly inclined to fix the
> > 2nd issue, but even if they did, we still have plenty of 4.5 and 4.6
> > installs that would hit problems.
> >
> > So, let's re-order with a few more anonymous structs & unions so that
> > the fields are laid out with a zero-length array always as the last
> > field. This seems to fix things with gcc-4.6, and the tftp-hpa pkg
> > continues to build & work.
>
> any complaints on this version ?
no love ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120428/dd276055/attachment.sig>
More information about the Libc-alpha
mailing list