Gaetan Nadon <[email protected]> writes: > On 14-02-12 12:57 PM, Keith Packard wrote: >> This function is supposed to be automatically replaced with os/strlcpy.c >> when not present in your C library. >> >> Something appears to be amiss here; I don't have strlcpy *or* strlcat in >> my glibc, and so configure correctly adds os/strlcpy.c and os/strlcat.c >> to the build. >> > I cannot reproduce the problem anymore. I retraced my commands from the > terminal, run make CC="gcc -D_FORTIFY_SOURCE=2" again, this time it works. > > This shows it is already defined: > > nadon@memsize:~/xorg/src/app/xclock$ gcc -dM -E - < /dev/null | grep > FORTIFY > #define _FORTIFY_SOURCE 2 > > There does not seem to be any harm in defining for all builds. If it is > not supported, it will be ignored. > > Let me know, and I can create a patch to add this in util-macros. It can > be conditionally added using AC_CHECK_DECLS. If it is already define, it > won't be added.
Yeah, we'll want a way to disable it; I've had one application that just
broke when _FORTIFY_SOURCE=2 was added. It was an older application
which allocate strings of variable length past the end of a struct and
accessed them with ((char *) ((s) + 1)), instead of declaring a
zero-length char array as the last struct member.
Old way:
struct foo {
int len
/* implicit array of chars here */
};
#define foo_chars(f) ((char *) ((f) + 1))
New way:
struct foo {
int len;
char s[0];
};
#define foo_chars(f) ((f)->s)
With _FORTIFY_SOURCE=2, a bunch of libc would get quite confused and end
up crashing the program. However, presumably Ubuntu has been building
the X server this way for a while, so it's almost certainly OK for
X. That's how I found the above problem; some Ubuntu user reported a
bug...
I certainly liked the effect -- the warnings generated were the most
useful we've found in this whole exercise, I think.
So, we could simply add
#ifndef _FORTIFY_SOURCE
#define _FORTIFY_SOURCE 2
#endif
to some X server header file, or you could do something fancier with the
configure macros. I'm easy, but I definitely want it somehow :-)
--
[email protected]
pgp4N9tXFbrxX.pgp
Description: PGP signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
