From feebf6746374aa04b12e9e3e51313a3a82c03530 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 23 Nov 2011 00:30:02 -0800 Subject: [PATCH 1/9] Limit the number of screens Xvfb will attempt to allocate memory for Commit f9e3a2955d2ca7 removing the MAXSCREEN limit left the screen number too unlimited, and allowed any positive int for a screen number: Xvfb :1 -screen 2147483647 1024x1024x8 Fatal server error: Not enough memory for screen 2147483647 Found by Parfait 0.3.7: Error: Integer overflow (CWE 190) Integer parameter of memory allocation function realloc() may overflow due to multiplication with constant value 1112 at line 293 of hw/vfb/InitOutput.c in function 'ddxProcessArgument'. Since the X11 connection setup only has a CARD8 for number of SCREENS, limit to 255 screens, which is also low enough to avoid overflow on the sizeof(*vfbScreens) * (screenNum + 1) calculation for realloc. Signed-off-by: Alan Coopersmith Reviewed-by: Jamey Sharp --- hw/vfb/InitOutput.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 3e5d05100..9a9905d8f 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -280,7 +280,9 @@ ddxProcessArgument(int argc, char *argv[], int i) int screenNum; CHECK_FOR_REQUIRED_ARGUMENTS(2); screenNum = atoi(argv[i+1]); - if (screenNum < 0) + /* The protocol only has a CARD8 for number of screens in the + connection setup block, so don't allow more than that. */ + if ((screenNum < 0) || (screenNum >= 255)) { ErrorF("Invalid screen number %d\n", screenNum); UseMsg(); From 84207def93e4489df8dca8e044ce544be8a3f845 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 28 Nov 2011 20:38:58 -0800 Subject: [PATCH 2/9] Disable building of tests requiring DDX functions when Xorg is not built Some test cases require linking with some sort of DDX - ideally we'd have a stub ddx for testing, but for now, since we link with the Xorg ddx, disable those tests when configured with --disable-xorg Fixes https://bugs.freedesktop.org/show_bug.cgi?id=43320 Signed-off-by: Alan Coopersmith Reviewed-by: Dan Nicholson Reviewed-by: Jeremy Huddleston --- test/Makefile.am | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 62c398c18..48393d39a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,21 +1,32 @@ if ENABLE_UNIT_TESTS -SUBDIRS= . xi2 -noinst_PROGRAMS = xkb input xtest list misc fixes xfree86 string +SUBDIRS= . +noinst_PROGRAMS = list string +if XORG +# Tests that require at least some DDX functions in order to fully link +# For now, requires xf86 ddx, could be adjusted to use another +SUBDIRS += xi2 +noinst_PROGRAMS += xkb input xtest misc fixes xfree86 +endif check_LTLIBRARIES = libxservertest.la TESTS=$(noinst_PROGRAMS) TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV) AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ -INCLUDES = $(XORG_INCS) -I$(top_srcdir)/hw/xfree86/parser \ - -I$(top_srcdir)/miext/cw -I$(top_srcdir)/hw/xfree86/ddc \ +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/miext/cw +if XORG +INCLUDES += -I$(top_srcdir)/hw/xfree86/parser \ + -I$(top_srcdir)/hw/xfree86/ddc \ -I$(top_srcdir)/hw/xfree86/i2c -I$(top_srcdir)/hw/xfree86/modes \ -I$(top_srcdir)/hw/xfree86/ramdac +endif TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) +if XORG if SPECIAL_DTRACE_OBJECTS TEST_LDADD += $(OS_LIB) $(DIX_LIB) endif +endif xkb_LDADD=$(TEST_LDADD) input_LDADD=$(TEST_LDADD) @@ -25,9 +36,10 @@ misc_LDADD=$(TEST_LDADD) fixes_LDADD=$(TEST_LDADD) xfree86_LDADD=$(TEST_LDADD) +libxservertest_la_LIBADD = $(XSERVER_LIBS) +if XORG nodist_libxservertest_la_SOURCES = $(top_builddir)/hw/xfree86/sdksyms.c -libxservertest_la_LIBADD = \ - $(XSERVER_LIBS) \ +libxservertest_la_LIBADD += \ $(top_builddir)/hw/xfree86/loader/libloader.la \ $(top_builddir)/hw/xfree86/os-support/libxorgos.la \ $(top_builddir)/hw/xfree86/common/libcommon.la \ @@ -37,7 +49,9 @@ libxservertest_la_LIBADD = \ $(top_builddir)/hw/xfree86/ramdac/libramdac.la \ $(top_builddir)/hw/xfree86/ddc/libddc.la \ $(top_builddir)/hw/xfree86/i2c/libi2c.la \ - $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \ + $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la +endif +libxservertest_la_LIBADD += \ $(top_builddir)/mi/libmi.la \ $(top_builddir)/os/libos.la \ @XORG_LIBS@ From 4be68b03128e958d2a6dc1b7feb3587329b9561b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 30 Nov 2011 19:39:51 -0800 Subject: [PATCH 3/9] Remove unused function checks from configure.ac & include/*.h.in The code that used getisax to check for MMX support was moved to pixman and removed from the X server by commit eb2d7fe02f9cbc. The code that used HAVE_MKSTEMP was deleted by the Xprint removal in commit 1c8bd318fbaf. All alloca calls were removed by the patch series end in commit 5e363500c8, and used custom X checks instead of the autoconf HAVE_ALLOCA anyway. I can find no record of HAVE_GETUID, HAVE_GETEUID, HAVE_LINK, HAVE_MEMMOVE, HAVE_MEMSET, HAVE_STRCHR, HAVE_STRRCHR, HAVE_GETOPT, HAVE_GETOPT_LONG, HAVE_DOPRNT, or HAVE_VPRINTF ever being used, and the calls to those functions are not wrapped in #ifdefs. (Most of those are in our baseline requirements of C89 & Unix98 anyway.) Signed-off-by: Alan Coopersmith Reviewed-by: Adam Jackson Reviewed-by: Mikhail Gusarov Reviewed-by: Gaetan Nadon --- configure.ac | 7 ++----- include/dix-config.h.in | 30 ------------------------------ include/xwin-config.h.in | 3 --- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/configure.ac b/configure.ac index e4fcba4a5..7e4871f61 100644 --- a/configure.ac +++ b/configure.ac @@ -213,11 +213,8 @@ AC_CHECK_FUNC([dlopen], [], AC_SUBST(DLOPEN_LIBS) dnl Checks for library functions. -AC_FUNC_VPRINTF -AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \ - strtol getopt getopt_long vsnprintf walkcontext backtrace \ - getisax getzoneid shmctl64 strcasestr ffs vasprintf]) -AC_FUNC_ALLOCA +AC_CHECK_FUNCS([vsnprintf walkcontext backtrace \ + getzoneid shmctl64 strcasestr ffs vasprintf]) AC_CHECK_FUNCS([strndup], [HAVE_STRNDUP=yes], [HAVE_STRNDUP=no]) AM_CONDITIONAL(NEED_STRNDUP, [test x$HAVE_STRNDUP = xno]) dnl Old HAS_* names used in os/*.c. diff --git a/include/dix-config.h.in b/include/dix-config.h.in index e1d3a9eaa..d5129fe9d 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -94,24 +94,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT - /* Have execinfo.h */ #undef HAVE_EXECINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H -/* Define to 1 if you have the `geteuid' function. */ -#undef HAVE_GETEUID - -/* Define to 1 if you have the `getisax' function. */ -#undef HAVE_GETISAX - -/* Define to 1 if you have the `getuid' function. */ -#undef HAVE_GETUID - /* Define to 1 if you have the `getzoneid' function. */ #undef HAVE_GETZONEID @@ -136,9 +124,6 @@ /* Define to 1 if you have the libdispatch (GCD) available */ #undef HAVE_LIBDISPATCH -/* Define to 1 if you have the `link' function. */ -#undef HAVE_LINK - /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_AGPGART_H @@ -148,9 +133,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_FB_H -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - /* Define to 1 if you have the header file. */ #undef HAVE_NDBM_H @@ -181,9 +163,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the `strchr' function. */ -#undef HAVE_STRCHR - /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H @@ -193,12 +172,6 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP -/* Define to 1 if you have the `strrchr' function. */ -#undef HAVE_STRRCHR - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - /* Define to 1 if SYSV IPC is available */ #undef HAVE_SYSV_IPC @@ -234,9 +207,6 @@ /* Have /dev/urandom */ #undef HAVE_URANDOM -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF diff --git a/include/xwin-config.h.in b/include/xwin-config.h.in index 13b51ca7f..8122f5543 100644 --- a/include/xwin-config.h.in +++ b/include/xwin-config.h.in @@ -20,9 +20,6 @@ /* Define to 1 if unsigned long is 64 bits. */ #undef _XSERVER64 -/* Do we require our own snprintf? */ -#undef NEED_SNPRINTF - /* Short vendor name */ #undef XVENDORNAMESHORT From d829a7c5cb42c979b58f3547136df5b05d906423 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 30 Nov 2011 22:20:09 -0800 Subject: [PATCH 4/9] Move to autoconf standard function name checks & defines Replace multiple methods of checking for functions with AC_CHECK_FUNCS Replace multiple methods of selecting fallback funcs with AC_REPLACE_FUNCS Replace HAS_* and NEED_* #defines with autogenerated HAVE_* Signed-off-by: Alan Coopersmith Reviewed-by: Adam Jackson Reviewed-by: Mikhail Gusarov Reviewed-by: Gaetan Nadon --- configure.ac | 36 ++++------------------ hw/dmx/config/Makefile.am | 3 -- hw/vfb/InitOutput.c | 26 ++++++++-------- hw/xwin/win.h | 4 +-- include/dix-config.h.in | 65 ++++++++++++++++++++------------------- include/os.h | 8 ++--- include/xkb-config.h.in | 3 -- mi/mibitblt.c | 2 +- os/Makefile.am | 16 ++-------- os/access.c | 28 ++++++++--------- os/connection.c | 6 ++-- os/osdep.h | 6 ---- os/strcasecmp.c | 4 +-- os/strcasestr.c | 2 +- os/strlcpy.c | 2 ++ 15 files changed, 84 insertions(+), 127 deletions(-) diff --git a/configure.ac b/configure.ac index 7e4871f61..d019366d9 100644 --- a/configure.ac +++ b/configure.ac @@ -213,31 +213,14 @@ AC_CHECK_FUNC([dlopen], [], AC_SUBST(DLOPEN_LIBS) dnl Checks for library functions. -AC_CHECK_FUNCS([vsnprintf walkcontext backtrace \ - getzoneid shmctl64 strcasestr ffs vasprintf]) -AC_CHECK_FUNCS([strndup], [HAVE_STRNDUP=yes], [HAVE_STRNDUP=no]) -AM_CONDITIONAL(NEED_STRNDUP, [test x$HAVE_STRNDUP = xno]) -dnl Old HAS_* names used in os/*.c. -AC_CHECK_FUNC([getdtablesize], - AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.])) -AC_CHECK_FUNC([getifaddrs], - AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.])) -AC_CHECK_FUNC([getpeereid], - AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.])) -AC_CHECK_FUNC([getpeerucred], - AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.])) -AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no) -AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno]) -AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function])) +AC_CHECK_FUNCS([backtrace ffs \ + getdtablesize getifaddrs getpeereid getpeerucred getzoneid \ + mmap shmctl64 strncasecmp vasprintf vsnprintf walkcontext]) +AC_REPLACE_FUNCS([strcasecmp strcasestr strlcat strlcpy strndup]) -AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno]) - -dnl Check for mmap support for Xvfb -AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.])) - -dnl Find the math libary +dnl Find the math libary, then check for cbrt function in it. AC_CHECK_LIB(m, sqrt) -AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function])) +AC_CHECK_FUNCS([cbrt]) AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h]) @@ -1238,13 +1221,6 @@ XKB_LIB='$(top_builddir)/xkb/libxkb.la' XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la' REQUIRED_MODULES="$REQUIRED_MODULES xkbfile" -AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1, - [Do not have 'strcasecmp'.])) -AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1, - [Do not have 'strncasecmp'.])) -AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1, - [Do not have 'strcasestr'.])) - PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"]) if test "x$have_libxdmcp" = xyes; then AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS]) diff --git a/hw/dmx/config/Makefile.am b/hw/dmx/config/Makefile.am index 75181436e..06588e7a1 100644 --- a/hw/dmx/config/Makefile.am +++ b/hw/dmx/config/Makefile.am @@ -21,10 +21,7 @@ BUILT_SOURCES = parser.c parser.h scanner.c MAINTAINERCLEANFILES = $(BUILT_SOURCES) libdmxconfig_a_SOURCES = $(LIBSRCS) - -if NEED_STRLCAT libdmxconfig_a_SOURCES += $(top_srcdir)/os/strlcpy.c -endif if GLX GLX_DEFS = @GL_CFLAGS@ diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 9a9905d8f..e1af5a471 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -48,12 +48,12 @@ from The Open Group. #include "mipointer.h" #include "micmap.h" #include -#ifdef HAS_MMAP +#ifdef HAVE_MMAP #include #ifndef MAP_FILE #define MAP_FILE 0 #endif -#endif /* HAS_MMAP */ +#endif /* HAVE_MMAP */ #include #include #ifndef WIN32 @@ -93,7 +93,7 @@ typedef struct unsigned int lineBias; CloseScreenProcPtr closeScreen; -#ifdef HAS_MMAP +#ifdef HAVE_MMAP int mmap_fd; char mmap_file[MAXPATHLEN]; #endif @@ -114,7 +114,7 @@ static vfbScreenInfo defaultScreenInfo = { .lineBias = VFB_DEFAULT_LINEBIAS, }; static Bool vfbPixmapDepths[33]; -#ifdef HAS_MMAP +#ifdef HAVE_MMAP static char *pfbdir = NULL; #endif typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType; @@ -158,7 +158,7 @@ ddxGiveUp(enum ExitCode error) switch (fbmemtype) { -#ifdef HAS_MMAP +#ifdef HAVE_MMAP case MMAPPED_FILE_FB: for (i = 0; i < vfbNumScreens; i++) { @@ -170,10 +170,10 @@ ddxGiveUp(enum ExitCode error) } } break; -#else /* HAS_MMAP */ +#else /* HAVE_MMAP */ case MMAPPED_FILE_FB: break; -#endif /* HAS_MMAP */ +#endif /* HAVE_MMAP */ #ifdef HAS_SHM case SHARED_MEMORY_FB: @@ -241,7 +241,7 @@ ddxUseMsg(void) ErrorF("-blackpixel n pixel value for black\n"); ErrorF("-whitepixel n pixel value for white\n"); -#ifdef HAS_MMAP +#ifdef HAVE_MMAP ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n"); #endif @@ -370,7 +370,7 @@ ddxProcessArgument(int argc, char *argv[], int i) return 2; } -#ifdef HAS_MMAP +#ifdef HAVE_MMAP if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */ { CHECK_FOR_REQUIRED_ARGUMENTS(1); @@ -378,7 +378,7 @@ ddxProcessArgument(int argc, char *argv[], int i) fbmemtype = MMAPPED_FILE_FB; return 2; } -#endif /* HAS_MMAP */ +#endif /* HAVE_MMAP */ #ifdef HAS_SHM if (strcmp (argv[i], "-shmem") == 0) /* -shmem */ @@ -523,7 +523,7 @@ vfbSaveScreen(ScreenPtr pScreen, int on) return TRUE; } -#ifdef HAS_MMAP +#ifdef HAVE_MMAP /* this flushes any changes to the screens out to the mmapped file */ static void @@ -608,7 +608,7 @@ vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) pvfb->pXWDHeader = NULL; } } -#endif /* HAS_MMAP */ +#endif /* HAVE_MMAP */ #ifdef HAS_SHM @@ -672,7 +672,7 @@ vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) pvfb->pXWDHeader = NULL; switch (fbmemtype) { -#ifdef HAS_MMAP +#ifdef HAVE_MMAP case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break; #else case MMAPPED_FILE_FB: break; diff --git a/hw/xwin/win.h b/hw/xwin/win.h index e2e946fb5..ac26d0181 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -143,12 +143,12 @@ #undef HANDLE #endif -#ifdef HAS_MMAP +#ifdef HAVE_MMAP #include #ifndef MAP_FILE #define MAP_FILE 0 #endif /* MAP_FILE */ -#endif /* HAS_MMAP */ +#endif /* HAVE_MMAP */ #include #include diff --git a/include/dix-config.h.in b/include/dix-config.h.in index d5129fe9d..3fb641367 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -51,27 +51,9 @@ /* Support XDM-AUTH*-1 */ #undef HASXDMAUTH -/* Define to 1 if you have the `getdtablesize' function. */ -#undef HAS_GETDTABLESIZE - -/* Define to 1 if you have the `getifaddrs' function. */ -#undef HAS_GETIFADDRS - -/* Define to 1 if you have the `getpeereid' function. */ -#undef HAS_GETPEEREID - -/* Define to 1 if you have the `getpeerucred' function. */ -#undef HAS_GETPEERUCRED - -/* Define to 1 if you have the `mmap' function. */ -#undef HAS_MMAP - /* Support SHM */ #undef HAS_SHM -/* Have the 'strlcpy' function */ -#undef HAS_STRLCPY - /* Define to 1 if you have the header file. */ #undef HAVE_ASM_MTRR_H @@ -81,7 +63,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_BYTESWAP_H -/* Define to 1 if you have cbrt */ +/* Define to 1 if you have the `cbrt' function. */ #undef HAVE_CBRT /* Define to 1 if you have the header file. */ @@ -100,6 +82,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `ffs' function. */ +#undef HAVE_FFS + +/* Define to 1 if you have the `getdtablesize' function. */ +#undef HAVE_GETDTABLESIZE + +/* Define to 1 if you have the `getifaddrs' function. */ +#undef HAVE_GETIFADDRS + +/* Define to 1 if you have the `getpeereid' function. */ +#undef HAVE_GETPEEREID + +/* Define to 1 if you have the `getpeerucred' function. */ +#undef HAVE_GETPEERUCRED + /* Define to 1 if you have the `getzoneid' function. */ #undef HAVE_GETZONEID @@ -133,6 +130,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_FB_H +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + /* Define to 1 if you have the header file. */ #undef HAVE_NDBM_H @@ -163,6 +163,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strcasestr' function. */ +#undef HAVE_STRCASESTR + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strlcat' function. */ +#undef HAVE_STRLCAT + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H @@ -402,18 +417,6 @@ /* Define to 64-bit byteswap macro */ #undef bswap_64 -/* Need the strcasecmp function. */ -#undef NEED_STRCASECMP - -/* Need the strncasecmp function. */ -#undef NEED_STRNCASECMP - -/* Need the strcasestr function. */ -#undef NEED_STRCASESTR - -/* Define to 1 if you have the `ffs' function. */ -#undef HAVE_FFS - /* The compiler supported TLS storage class, prefering initial-exec if tls_model is supported */ #undef TLS diff --git a/include/os.h b/include/os.h index 22983814b..1fd5367c4 100644 --- a/include/os.h +++ b/include/os.h @@ -472,22 +472,22 @@ extern _X_EXPORT void ddxGiveUp(enum ExitCode error); extern _X_EXPORT int TimeSinceLastInputEvent(void); /* strcasecmp.c */ -#if NEED_STRCASECMP +#ifndef HAVE_STRCASECMP #define strcasecmp xstrcasecmp extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2); #endif -#if NEED_STRNCASECMP +#ifndef HAVE_STRNCASECMP #define strncasecmp xstrncasecmp extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n); #endif -#if NEED_STRCASESTR +#ifndef HAVE_STRCASESTR #define strcasestr xstrcasestr extern _X_EXPORT char *xstrcasestr(const char *s, const char *find); #endif -#ifndef HAS_STRLCPY +#ifndef HAVE_STRLCPY extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz); extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz); #endif diff --git a/include/xkb-config.h.in b/include/xkb-config.h.in index d3cdd1916..7b6a671b8 100644 --- a/include/xkb-config.h.in +++ b/include/xkb-config.h.in @@ -29,7 +29,4 @@ /* XKB output dir for compiled keymaps. */ #undef XKM_OUTPUT_DIR -/* Do not have `strcasecmp'. */ -#undef NEED_STRCASECMP - #endif /* _XKB_CONFIG_H_ */ diff --git a/mi/mibitblt.c b/mi/mibitblt.c index 49e17bde6..2dfff1451 100644 --- a/mi/mibitblt.c +++ b/mi/mibitblt.c @@ -63,7 +63,7 @@ SOFTWARE. #include #include "servermd.h" -#ifndef HAS_FFS +#ifndef HAVE_FFS extern int ffs(int); #endif diff --git a/os/Makefile.am b/os/Makefile.am index 8dd809531..88914852f 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -4,7 +4,6 @@ AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS) SECURERPC_SRCS = rpcauth.c XDMCP_SRCS = xdmcp.c -STRLCAT_SRCS = strlcat.c strlcpy.c XORG_SRCS = log.c libos_la_SOURCES = \ @@ -20,14 +19,12 @@ libos_la_SOURCES = \ osdep.h \ osinit.c \ utils.c \ - strcasecmp.c \ - strcasestr.c \ xdmauth.c \ xsha1.c \ xstrans.c \ xprintf.c \ $(XORG_SRCS) -libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) +libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) $(LTLIBOBJS) if SECURE_RPC libos_la_SOURCES += $(SECURERPC_SRCS) @@ -37,16 +34,7 @@ if XDMCP libos_la_SOURCES += $(XDMCP_SRCS) endif -if NEED_STRLCAT -libos_la_SOURCES += $(STRLCAT_SRCS) -endif - -if NEED_STRNDUP -libos_la_SOURCES += $(STRNDUP_SRCS) -endif - -EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \ - $(XDMCP_SRCS) $(STRLCAT_SRCS) +EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS) if SPECIAL_DTRACE_OBJECTS # Generate dtrace object code for probes in libos & libdix diff --git a/os/access.c b/os/access.c index 159894007..0800c7f73 100644 --- a/os/access.c +++ b/os/access.c @@ -106,7 +106,7 @@ SOFTWARE. #include #endif /* TCPCONN || STREAMSCONN */ -#ifdef HAS_GETPEERUCRED +#ifdef HAVE_GETPEERUCRED # include # ifdef sun # include @@ -146,7 +146,7 @@ SOFTWARE. #endif #endif -#ifdef HAS_GETIFADDRS +#ifdef HAVE_GETIFADDRS #include #endif @@ -495,7 +495,7 @@ in6_fillscopeid(struct sockaddr_in6 *sin6) void DefineSelf (int fd) { -#ifndef HAS_GETIFADDRS +#ifndef HAVE_GETIFADDRS char *cp, *cplim; # ifdef USE_SIOCGLIFCONF struct sockaddr_storage buf[16]; @@ -510,7 +510,7 @@ DefineSelf (int fd) register struct ifreq *ifr; # endif void * bufptr = buf; -#else /* HAS_GETIFADDRS */ +#else /* HAVE_GETIFADDRS */ struct ifaddrs * ifap, *ifr; #endif int len; @@ -518,7 +518,7 @@ DefineSelf (int fd) int family; register HOST *host; -#ifndef HAS_GETIFADDRS +#ifndef HAVE_GETIFADDRS len = sizeof(buf); @@ -689,7 +689,7 @@ DefineSelf (int fd) } if (bufptr != buf) free(bufptr); -#else /* HAS_GETIFADDRS */ +#else /* HAVE_GETIFADDRS */ if (getifaddrs(&ifap) < 0) { ErrorF("Warning: getifaddrs returns %s\n", strerror(errno)); return; @@ -777,7 +777,7 @@ DefineSelf (int fd) } /* for */ freeifaddrs(ifap); -#endif /* HAS_GETIFADDRS */ +#endif /* HAVE_GETIFADDRS */ /* * add something of FamilyLocalHost @@ -798,7 +798,7 @@ DefineSelf (int fd) } } } -#endif /* hpux && !HAS_IFREQ */ +#endif /* hpux && !HAVE_IFREQ */ #ifdef XDMCP void @@ -1091,14 +1091,14 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid) int GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) { -#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) +#if defined(HAVE_GETPEEREID) || defined(HAVE_GETPEERUCRED) || defined(SO_PEERCRED) int fd; XtransConnInfo ci; LocalClientCredRec *lcc; -#ifdef HAS_GETPEEREID +#ifdef HAVE_GETPEEREID uid_t uid; gid_t gid; -#elif defined(HAS_GETPEERUCRED) +#elif defined(HAVE_GETPEERUCRED) ucred_t *peercred = NULL; const gid_t *gids; #elif defined(SO_PEERCRED) @@ -1109,7 +1109,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) if (client == NULL) return -1; ci = ((OsCommPtr)client->osPrivate)->trans_conn; -#if !(defined(sun) && defined(HAS_GETPEERUCRED)) +#if !(defined(sun) && defined(HAVE_GETPEERUCRED)) /* Most implementations can only determine peer credentials for Unix * domain sockets - Solaris getpeerucred can work with a bit more, so * we just let it tell us if the connection type is supported or not @@ -1125,7 +1125,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) lcc = *lccp; fd = _XSERVTransGetConnectionNumber(ci); -#ifdef HAS_GETPEEREID +#ifdef HAVE_GETPEEREID if (getpeereid(fd, &uid, &gid) == -1) { FreeLocalClientCreds(lcc); return -1; @@ -1134,7 +1134,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) lcc->egid = gid; lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET; return 0; -#elif defined(HAS_GETPEERUCRED) +#elif defined(HAVE_GETPEERUCRED) if (getpeerucred(fd, &peercred) < 0) { FreeLocalClientCreds(lcc); return -1; diff --git a/os/connection.c b/os/connection.c index c5fc5a07e..6f480deb6 100644 --- a/os/connection.c +++ b/os/connection.c @@ -114,7 +114,7 @@ SOFTWARE. #define Pid_t pid_t -#ifdef HAS_GETPEERUCRED +#ifdef HAVE_GETPEERUCRED # include # include #endif @@ -122,7 +122,7 @@ SOFTWARE. #ifdef XSERVER_DTRACE # include typedef const char *string; -# ifndef HAS_GETPEERUCRED +# ifndef HAVE_GETPEERUCRED # define zoneid_t int # endif # include "../dix/Xserver-dtrace.h" @@ -282,7 +282,7 @@ InitConnectionLimits(void) lastfdesc = sysconf(_SC_OPEN_MAX) - 1; #endif -#ifdef HAS_GETDTABLESIZE +#ifdef HAVE_GETDTABLESIZE if (lastfdesc < 0) lastfdesc = getdtablesize() - 1; #endif diff --git a/os/osdep.h b/os/osdep.h index 087e36d06..72bd7d762 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -103,12 +103,6 @@ SOFTWARE. /* MAXSELECT is the number of fds that select() can handle */ #define MAXSELECT (sizeof(fd_set) * NBBY) -#ifndef HAS_GETDTABLESIZE -#if !defined(SVR4) && !defined(SYSV) -#define HAS_GETDTABLESIZE -#endif -#endif - #include #if defined(XDMCP) || defined(HASXDMAUTH) diff --git a/os/strcasecmp.c b/os/strcasecmp.c index ad6da6a10..cf100baf4 100644 --- a/os/strcasecmp.c +++ b/os/strcasecmp.c @@ -34,7 +34,7 @@ #include #include "dix.h" -#ifdef NEED_STRCASECMP +#ifndef HAVE_STRCASECMP int xstrcasecmp(const char *str1, const char *str2) { @@ -50,7 +50,7 @@ xstrcasecmp(const char *str1, const char *str2) } #endif -#ifdef NEED_STRNCASECMP +#ifndef HAVE_STRNCASECMP int xstrncasecmp(const char *s1, const char *s2, size_t n) { diff --git a/os/strcasestr.c b/os/strcasestr.c index f89b2f2dc..a20a6cc33 100644 --- a/os/strcasestr.c +++ b/os/strcasestr.c @@ -41,7 +41,7 @@ /* * Find the first occurrence of find in s, ignore case. */ -#ifdef NEED_STRCASESTR +#ifndef HAVE_STRCASESTR char * xstrcasestr(const char *s, const char *find) { diff --git a/os/strlcpy.c b/os/strlcpy.c index 2e55b2e63..7ffb64cd6 100644 --- a/os/strlcpy.c +++ b/os/strlcpy.c @@ -22,6 +22,7 @@ #include #include "os.h" +#ifndef HAVE_STRLCPY /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). @@ -52,3 +53,4 @@ strlcpy(char *dst, const char *src, size_t siz) return s - src - 1; /* count does not include NUL */ } +#endif From 8b6a75009746db4b8e2e180210ac097e35136bcd Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 30 Nov 2011 23:01:34 -0800 Subject: [PATCH 5/9] Fix gcc warnings about redundant declarations of fallback functions Ensure ffs, strndup, strlcat, etc. aren't defined by our headers if they're already defined in the system headers. This does export the HAVE_FFS, HAVE_STRNDUP, etc. definitions to drivers, but if you built the Xserver with a libc that had those, and then build the drivers with a less capable libc, you're going to have problems anyway, and this should solve some reported problems with conflicts between our strndup definition and gcc magic for it. Signed-off-by: Alan Coopersmith Reviewed-by: Adam Jackson --- hw/xfree86/xaa/xaaTables.c | 3 +++ include/dix.h | 2 ++ include/xorg-server.h.in | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/hw/xfree86/xaa/xaaTables.c b/hw/xfree86/xaa/xaaTables.c index c7fa28af3..dbeb4a269 100644 --- a/hw/xfree86/xaa/xaaTables.c +++ b/hw/xfree86/xaa/xaaTables.c @@ -1,3 +1,6 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif #include "xaalocal.h" /* * This is a table of 24-bit values, indexed with an 8-bit byte value, then diff --git a/include/dix.h b/include/dix.h index 34661f3b6..f98c87b04 100644 --- a/include/dix.h +++ b/include/dix.h @@ -529,7 +529,9 @@ extern _X_EXPORT void ScreenRestructured (ScreenPtr pScreen); #endif +#ifndef HAVE_FFS extern _X_EXPORT int ffs(int i); +#endif /* diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in index b10b9949e..8086f32ae 100644 --- a/include/xorg-server.h.in +++ b/include/xorg-server.h.in @@ -37,6 +37,27 @@ /* Support SHM */ #undef HAS_SHM +/* Define to 1 if you have the `ffs' function. */ +#undef HAVE_FFS + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strcasestr' function. */ +#undef HAVE_STRCASESTR + +/* Define to 1 if you have the `strlcat' function. */ +#undef HAVE_STRLCAT + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + /* Support IPv6 for TCP connections */ #undef IPv6 From e4dcf580f007d6adcf5b0c639865d7aaab1a319d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 1 Dec 2011 23:45:42 -0800 Subject: [PATCH 6/9] LoaderOpen returns either a valid pointer or NULL, so don't check for < 0 Fixes Sun cc warning that was recently elevated to error by the stricter default CFLAGS changes to xorg-macros: "loadmod.c", line 914: improper pointer/integer combination: op "<" Should have been changed when commit ab7f057ce9df4e905b12 changed the LoaderOpen return type from int to void *. Changes log message when file is found but dlopen() fails from: (EE) LoadModule: Module dbe does not have a dbeModuleData data object. (EE) Failed to load module "dbe" (invalid module, 0) to: (EE) Failed to load module "dbe" (loader failed, 7) Signed-off-by: Alan Coopersmith Reviewed-by: Adam Jackson --- hw/xfree86/loader/loadmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index c697d74ed..5b9f8d1c3 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -911,7 +911,7 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, goto LoadModule_fail; } ret->handle = LoaderOpen(found, errmaj, errmin); - if (ret->handle < 0) + if (ret->handle == NULL) goto LoadModule_fail; ret->path = strdup(found); From c19c55a93ab1bc6db56075ca34d6e1c3f522f622 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 2 Dec 2011 00:09:07 -0800 Subject: [PATCH 7/9] Fix builds of Xnest & Xephyr with Solaris Studio compilers Required in order to build with Studio cc now that xorg-macros is setting -errwarn=E_FUNC_HAS_NO_RETURN_STMT since a bug in the Solaris system headers causes the noreturn attribute to not be correctly applied to the exit() prototype in when building with Studio instead of gcc. Otherwise compiler exits with errors: "Display.c", line 65: Function has no return statement : x_io_error_handler "hostx.c", line 341: Function has no return statement : x_io_error_handler Uses Studio-specific pragma instead of adding another exit() prototype with a noreturn attribute to avoid causing gcc to warn about having a redundant prototype for the exit() function. Signed-off-by: Alan Coopersmith Reviewed-by: Mikhail Gusarov --- hw/kdrive/ephyr/hostx.c | 5 +++++ hw/xnest/Display.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 47a6681c4..ebe4e52ed 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -332,6 +332,11 @@ hostx_set_title (char *title) ephyrTitle = title; } +#ifdef __SUNPRO_C +/* prevent "Function has no return statement" error for x_io_error_handler */ +#pragma does_not_return(exit) +#endif + static int _X_NORETURN x_io_error_handler (Display *dpy) { ErrorF("Lost connection to X server: %s\n", strerror(errno)); diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 7acad755c..3176b60d7 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -55,6 +55,11 @@ Pixmap xnestScreenSaverPixmap; XlibGC xnestBitmapGC; unsigned long xnestEventMask; +#ifdef __SUNPRO_C +/* prevent "Function has no return statement" error for x_io_error_handler */ +#pragma does_not_return(exit) +#endif + static int _X_NORETURN x_io_error_handler (Display *dpy) { ErrorF("Lost connection to X server: %s\n", strerror(errno)); From 427cb53fddf0c517d1fd1025a87b1104735edd2a Mon Sep 17 00:00:00 2001 From: Gaetan Nadon Date: Sat, 3 Dec 2011 21:23:21 -0500 Subject: [PATCH 8/9] autoconf: remove redundant AC_PROG_MAKE_SET Already included during Automake initialization. After the patch, no change: configure:3893: checking whether make sets $(MAKE) configure:3915: result: yes Signed-off-by: Gaetan Nadon Reviewed-by: Alan Coopersmith Signed-off-by: Alan Coopersmith --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index d019366d9..cd26a2bd7 100644 --- a/configure.ac +++ b/configure.ac @@ -76,7 +76,6 @@ AC_PROG_LN_S AC_LIBTOOL_WIN32_DLL AC_DISABLE_STATIC AC_PROG_LIBTOOL -AC_PROG_MAKE_SET PKG_PROG_PKG_CONFIG AC_PROG_LEX AC_PROG_YACC From e89b0324da89ba5c0ba64af1ef46a12b7f55f879 Mon Sep 17 00:00:00 2001 From: Gaetan Nadon Date: Sat, 3 Dec 2011 21:23:51 -0500 Subject: [PATCH 9/9] autoconf: the minimum required level for autoconf is 2.60 The toolchain requirements are documented here: http://www.x.org/wiki/ModularDevelopersGuide#Required_Tools Note that autoconf features only found in versions later than 2.60 must not be used. Signed-off-by: Gaetan Nadon Reviewed-by: Alan Coopersmith Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cd26a2bd7..e9043b6e9 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl an unwitting cast of miscellaneous others dnl dnl Process this file with autoconf to create configure. -AC_PREREQ(2.57) +AC_PREREQ(2.60) AC_INIT([xorg-server], 1.11.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) RELEASE_DATE="2011-11-20" AC_CONFIG_SRCDIR([Makefile.am])