aboutsummaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/055_nx-X11_imake-Werror-format-security.full.patch1090
-rw-r--r--debian/patches/series1
2 files changed, 1091 insertions, 0 deletions
diff --git a/debian/patches/055_nx-X11_imake-Werror-format-security.full.patch b/debian/patches/055_nx-X11_imake-Werror-format-security.full.patch
new file mode 100644
index 000000000..6e5b4c80e
--- /dev/null
+++ b/debian/patches/055_nx-X11_imake-Werror-format-security.full.patch
@@ -0,0 +1,1090 @@
+Description: Fix FTBFS when compiled with -Werror=format-security
+Author: Orion Poplawski <orion@cora.nwra.com>
+diff -up a/nx-X11/config/imake/imake.c b/nx-X11/config/imake/imake.c
+--- a/nx-X11/config/imake/imake.c 2014-01-04 13:39:35.000000000 -0700
++++ b/nx-X11/config/imake/imake.c 2014-01-24 13:55:53.940697330 -0700
+@@ -7,8 +7,6 @@
+ * be passed to the template file. *
+ * *
+ ***************************************************************************/
+-/* $XFree86: xc/config/imake/imake.c,v 3.63tsi Exp $ */
+-
+ /*
+ *
+ Copyright (c) 1985, 1986, 1987, 1998 The Open Group
+@@ -153,23 +151,14 @@ in this Software without prior written a
+ #endif
+ #include <stdlib.h>
+ #include <stdio.h>
+-#ifdef MONOLITH
+-# include "Xosdefs.h"
+-#else
+-# include <X11/Xosdefs.h>
+-#endif
++#include <stdarg.h>
++#include <X11/Xfuncproto.h>
++#include <X11/Xosdefs.h>
+ #include <string.h>
+ #include <ctype.h>
+ #ifdef WIN32
+ # include "Xw32defs.h"
+ #endif
+-#if 0
+-#ifndef X_NOT_POSIX
+-# ifndef _POSIX_SOURCE
+-# define _POSIX_SOURCE
+-# endif
+-#endif
+-#endif
+ #include <sys/types.h>
+ #include <fcntl.h>
+ #ifdef X_NOT_POSIX
+@@ -231,22 +220,16 @@ typedef union wait waitType;
+ # define WIFEXITED(w) waitCode(w)
+ # endif
+ #endif /* X_NOT_POSIX */
+-# include <stdlib.h>
+-#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
+-char *malloc(), *realloc();
+-#endif /* macII */
++#include <stdlib.h>
+ #include <errno.h>
+ #ifdef __minix_vmd
+-#define USE_FREOPEN 1
++# define USE_FREOPEN 1
+ #endif
+
+-#if !((defined(sun) && !defined(SVR4)) || defined(macII))
+-#define USE_STRERROR 1
+-#endif
+ #ifndef WIN32
+-#include <sys/utsname.h>
++# include <sys/utsname.h>
+ #else
+-#include <windows.h>
++# include <windows.h>
+ #endif
+ #ifndef SYS_NMLN
+ # ifdef _SYS_NMLN
+@@ -256,39 +239,22 @@ char *malloc(), *realloc();
+ # endif
+ #endif
+ #if defined(linux) || defined(__GNU__) || defined(__GLIBC__)
+-#include <limits.h>
+-#include <stdio.h>
++# include <limits.h>
++# include <stdio.h>
+ #endif
+ #ifdef __QNX__
+-#include <unix.h>
+-#endif
+-
+-/*
+- * This define of strerror is copied from (and should be identical to)
+- * Xos.h, which we don't want to include here for bootstrapping reasons.
+- */
+-#ifndef USE_STRERROR
+-# ifndef strerror
+-extern char *sys_errlist[];
+-extern int sys_nerr;
+-# define strerror(n) \
+- (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
+-# endif
++# include <unix.h>
+ #endif
+
+ #if defined(__NetBSD__) /* see code clock in init() below */
+-#include <sys/utsname.h>
+-#endif
+-
+-#if !(defined(Lynx) || defined(__Lynx__) || (defined(SVR4) && !defined(sun))) && !defined (__CYGWIN__)
+-#define HAS_MKSTEMP
++# include <sys/utsname.h>
+ #endif
+
+ typedef unsigned char boolean;
+ #define TRUE 1
+ #define FALSE 0
+
+-# include "imakemdep.h"
++#include "imakemdep.h"
+ #ifdef CROSSCOMPILE
+ # include "imakemdep_cpp.h"
+ #endif
+@@ -305,7 +271,7 @@ int xvariables[10];
+ #endif
+
+ #ifndef PATH_MAX
+-#define PATH_MAX 1024
++# define PATH_MAX 1024
+ #endif
+
+ /*
+@@ -331,11 +297,13 @@ void KludgeOutputLine(char **), KludgeRe
+ # endif
+ #endif
+
+-char *cpp = NULL;
++const char *cpp = NULL;
+
+-char *tmpMakefile = "/tmp/Imf.XXXXXX";
+-char *tmpImakefile = "/tmp/IIf.XXXXXX";
+-char *make_argv[ ARGUMENTS ] = {
++const char *tmpMakefile;
++const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX";
++const char *tmpImakefile;
++const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX";
++const char *make_argv[ ARGUMENTS ] = {
+ #ifdef WIN32
+ "nmake"
+ #else
+@@ -345,53 +313,53 @@ char *make_argv[ ARGUMENTS ] = {
+
+ int make_argindex;
+ int cpp_argindex;
+-char *Imakefile = NULL;
+-char *Makefile = "Makefile";
+-char *Template = "Imake.tmpl";
+-char *ImakefileC = "Imakefile.c";
++const char *Imakefile = NULL;
++const char *Makefile = "Makefile";
++const char *Template = "Imake.tmpl";
++const char *ImakefileC = "Imakefile.c";
+ boolean haveImakefileC = FALSE;
+-char *cleanedImakefile = NULL;
+-char *program;
+-char *FindImakefile(char *Imakefile);
+-char *ReadLine(FILE *tmpfd, char *tmpfname);
+-char *CleanCppInput(char *imakefile);
+-char *Strdup(char *cp);
++const char *cleanedImakefile = NULL;
++const char *program;
++const char *FindImakefile(const char *Imakefile);
++char *ReadLine(FILE *tmpfd, const char *tmpfname);
++const char *CleanCppInput(const char *imakefile);
++char *Strdup(const char *cp);
+ char *Emalloc(int size);
+-void LogFatalI(char *s, int i), LogFatal(char *x0, char *x1),
+- LogMsg(char *x0, char *x1);
++void LogFatal(const char *x0, ...) _X_ATTRIBUTE_PRINTF(1, 2);
++void LogMsg(const char *x0, ...) _X_ATTRIBUTE_PRINTF(1, 2);
+
+ void showit(FILE *fd);
+ void wrapup(void);
+ void init(void);
+-void AddMakeArg(char *arg);
+-void AddCppArg(char *arg);
++void AddMakeArg(const char *arg);
++void AddCppArg(const char *arg);
+ #ifdef CROSSCOMPILE
+ char *CrossCompileCPP(void);
+ #endif
+ void SetOpts(int argc, char **argv);
+-void CheckImakefileC(char *masterc);
+-void cppit(char *imakefile, char *template, char *masterc,
+- FILE *outfd, char *outfname);
++void CheckImakefileC(const char *masterc);
++void cppit(const char *imakefile, const char *template, const char *masterc,
++ FILE *outfd, const char *outfname);
+ void makeit(void);
+-void CleanCppOutput(FILE *tmpfd, char *tmpfname);
++void CleanCppOutput(FILE *tmpfd, const char *tmpfname);
+ boolean isempty(char *line);
+-void writetmpfile(FILE *fd, char *buf, int cnt, char *fname);
++void writetmpfile(FILE *fd, const char *buf, int cnt, const char *fname);
+ #ifdef SIGNALRETURNSINT
+ int catch(int sig);
+ #else
+ void catch(int sig);
+ #endif
+-void showargs(char **argv);
+-boolean optional_include(FILE *inFile, char *defsym, char *fname);
+-void doit(FILE *outfd, char *cmd, char **argv);
++void showargs(const char **argv);
++boolean optional_include(FILE *inFile, const char *defsym, const char *fname);
++void doit(FILE *outfd, const char *cmd, const char **argv);
+ boolean define_os_defaults(FILE *inFile);
+ #ifdef CROSSCOMPILE
+ static void get_cross_compile_dir(FILE *inFile);
+ #endif
+ #ifdef CROSSCOMPILEDIR
+-char *CrossCompileDir = CROSSCOMPILEDIR;
++const char *CrossCompileDir = CROSSCOMPILEDIR;
+ #else
+-char *CrossCompileDir = "";
++const char *CrossCompileDir = "";
+ #endif
+ boolean CrossCompiling = FALSE;
+
+@@ -428,24 +396,25 @@ main(int argc, char *argv[])
+ if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL)
+ LogFatal("Cannot create temporary file %s.", tmpMakefile);
+ } else {
+-#ifdef HAS_MKSTEMP
++#ifdef HAVE_MKSTEMP
+ int fd;
+ #endif
+- tmpMakefile = Strdup(tmpMakefile);
+-#ifndef HAS_MKSTEMP
+- if (mktemp(tmpMakefile) == NULL ||
+- (tmpfd = fopen(tmpMakefile, "w+")) == NULL) {
+- LogFatal("Cannot create temporary file %s.", tmpMakefile);
++ char *tmpMakefileName = Strdup(tmpMakefileTemplate);
++#ifndef HAVE_MKSTEMP
++ if (mktemp(tmpMakefileName) == NULL ||
++ (tmpfd = fopen(tmpMakefileName, "w+")) == NULL) {
++ LogFatal("Cannot create temporary file %s.", tmpMakefileName);
+ }
+ #else
+- fd = mkstemp(tmpMakefile);
++ fd = mkstemp(tmpMakefileName);
+ if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) {
+ if (fd != -1) {
+- unlink(tmpMakefile); close(fd);
++ unlink(tmpMakefileName); close(fd);
+ }
+- LogFatal("Cannot create temporary file %s.", tmpMakefile);
++ LogFatal("Cannot create temporary file %s.", tmpMakefileName);
+ }
+ #endif
++ tmpMakefile = tmpMakefileName;
+ }
+ AddMakeArg("-f");
+ AddMakeArg( tmpMakefile );
+@@ -498,7 +467,7 @@ void
+ catch(int sig)
+ {
+ errno = 0;
+- LogFatalI("Signal %d.", sig);
++ LogFatal("Signal %d.", sig);
+ }
+
+ /*
+@@ -572,21 +541,21 @@ init(void)
+ }
+
+ void
+-AddMakeArg(char *arg)
++AddMakeArg(const char *arg)
+ {
+ errno = 0;
+ if (make_argindex >= ARGUMENTS-1)
+- LogFatal("Out of internal storage.", "");
++ LogFatal("Out of internal storage.");
+ make_argv[ make_argindex++ ] = arg;
+ make_argv[ make_argindex ] = NULL;
+ }
+
+ void
+-AddCppArg(char *arg)
++AddCppArg(const char *arg)
+ {
+ errno = 0;
+ if (cpp_argindex >= ARGUMENTS-1)
+- LogFatal("Out of internal storage.", "");
++ LogFatal("Out of internal storage.");
+ cpp_argv[ cpp_argindex++ ] = arg;
+ cpp_argv[ cpp_argindex ] = NULL;
+ }
+@@ -618,7 +587,7 @@ SetOpts(int argc, char **argv)
+ else {
+ argc--, argv++;
+ if (! argc)
+- LogFatal("No description arg after -f flag", "");
++ LogFatal("No description arg after -f flag");
+ Imakefile = argv[0];
+ }
+ } else if (argv[0][1] == 's') {
+@@ -628,7 +597,7 @@ SetOpts(int argc, char **argv)
+ else {
+ argc--, argv++;
+ if (!argc)
+- LogFatal("No description arg after -s flag", "");
++ LogFatal("No description arg after -s flag");
+ Makefile = ((argv[0][0] == '-') && !argv[0][1]) ?
+ NULL : argv[0];
+ }
+@@ -642,7 +611,7 @@ SetOpts(int argc, char **argv)
+ else {
+ argc--, argv++;
+ if (! argc)
+- LogFatal("No description arg after -T flag", "");
++ LogFatal("No description arg after -T flag");
+ Template = argv[0];
+ }
+ } else if (argv[0][1] == 'C') {
+@@ -651,7 +620,7 @@ SetOpts(int argc, char **argv)
+ else {
+ argc--, argv++;
+ if (! argc)
+- LogFatal("No imakeCfile arg after -C flag", "");
++ LogFatal("No imakeCfile arg after -C flag");
+ ImakefileC = argv[0];
+ }
+ } else if (argv[0][1] == 'v') {
+@@ -667,10 +636,10 @@ SetOpts(int argc, char **argv)
+ if (!cpp)
+ {
+ AddCppArg("-E");
+-#ifdef __GNUC__
++# ifdef __GNUC__
+ if (verbose)
+ AddCppArg("-v");
+-#endif
++# endif
+ cpp = DEFAULT_CC;
+ }
+ # else
+@@ -686,8 +655,8 @@ SetOpts(int argc, char **argv)
+ AddCppArg(ImakefileC);
+ }
+
+-char *
+-FindImakefile(char *Imakefile)
++const char *
++FindImakefile(const char *Imakefile)
+ {
+ if (Imakefile) {
+ if (access(Imakefile, R_OK) < 0)
+@@ -695,7 +664,7 @@ FindImakefile(char *Imakefile)
+ } else {
+ if (access("Imakefile", R_OK) < 0) {
+ if (access("imakefile", R_OK) < 0)
+- LogFatal("No description file.", "");
++ LogFatal("No description file.");
+ else
+ Imakefile = "imakefile";
+ } else
+@@ -704,44 +673,50 @@ FindImakefile(char *Imakefile)
+ return(Imakefile);
+ }
+
+-void
+-LogFatalI(char *s, int i)
++static void _X_ATTRIBUTE_PRINTF(1, 0)
++vLogMsg(const char *fmt, va_list args)
+ {
+- /*NOSTRICT*/
+- LogFatal(s, (char *)(long)i);
++ int error_number = errno;
++
++ if (error_number) {
++ fprintf(stderr, "%s: ", program);
++ fprintf(stderr, "%s\n", strerror(error_number));
++ }
++ fprintf(stderr, "%s: ", program);
++ vfprintf(stderr, fmt, args);
++ fprintf(stderr, "\n");
+ }
+
+ void
+-LogFatal(char *x0, char *x1)
++LogFatal(const char *fmt, ...)
+ {
+ static boolean entered = FALSE;
++ va_list args;
+
+ if (entered)
+ return;
+ entered = TRUE;
+
+- LogMsg(x0, x1);
++ va_start(args, fmt);
++ vLogMsg(fmt, args);
++ va_end(args);
+ fprintf(stderr, " Stop.\n");
+ wrapup();
+ exit(1);
+ }
+
+ void
+-LogMsg(char *x0, char *x1)
++LogMsg(const char *fmt, ...)
+ {
+- int error_number = errno;
++ va_list args;
+
+- if (error_number) {
+- fprintf(stderr, "%s: ", program);
+- fprintf(stderr, "%s\n", strerror(error_number));
+- }
+- fprintf(stderr, "%s: ", program);
+- fprintf(stderr, x0, x1);
+- fprintf(stderr, "\n");
++ va_start(args, fmt);
++ vLogMsg(fmt, args);
++ va_end(args);
+ }
+
+ void
+-showargs(char **argv)
++showargs(const char **argv)
+ {
+ for (; *argv; argv++)
+ fprintf(stderr, "%s ", *argv);
+@@ -751,7 +726,7 @@ showargs(char **argv)
+ #define ImakefileCHeader "/* imake - temporary file */"
+
+ void
+-CheckImakefileC(char *masterc)
++CheckImakefileC(const char *masterc)
+ {
+ char mkcbuf[1024];
+ FILE *inFile;
+@@ -767,7 +742,8 @@ CheckImakefileC(char *masterc)
+ fclose(inFile);
+ LogFatal("Refuse to overwrite: %s", masterc);
+ }
+- fclose(inFile);
++ else
++ fclose(inFile);
+ }
+ }
+
+@@ -778,7 +754,7 @@ CheckImakefileC(char *masterc)
+ #define OverrideWarning "Warning: local file \"%s\" overrides global macros."
+
+ boolean
+-optional_include(FILE *inFile, char *defsym, char *fname)
++optional_include(FILE *inFile, const char *defsym, const char *fname)
+ {
+ errno = 0;
+ if (access(fname, R_OK) == 0) {
+@@ -790,7 +766,7 @@ optional_include(FILE *inFile, char *def
+ }
+
+ void
+-doit(FILE *outfd, char *cmd, char **argv)
++doit(FILE *outfd, const char *cmd, const char **argv)
+ {
+ int pid;
+ waitType status;
+@@ -805,18 +781,18 @@ doit(FILE *outfd, char *cmd, char **argv
+ if (status < 0)
+ LogFatal("Cannot spawn %s.", cmd);
+ if (status > 0)
+- LogFatalI("Exit code %d.", status);
++ LogFatal("Exit code %d.", status);
+ #else
+ pid = fork();
+ if (pid < 0)
+- LogFatal("Cannot fork.", "");
++ LogFatal("Cannot fork.");
+ if (pid) { /* parent... simply wait */
+ while (wait(&status) > 0) {
+ errno = 0;
+ if (WIFSIGNALED(status))
+- LogFatalI("Signal %d.", waitSig(status));
++ LogFatal("Signal %d.", waitSig(status));
+ if (WIFEXITED(status) && waitCode(status))
+- LogFatalI("Exit code %d.", waitCode(status));
++ LogFatal("Exit code %d.", waitCode(status));
+ }
+ }
+ else { /* child... dup and exec cmd */
+@@ -832,7 +808,7 @@ doit(FILE *outfd, char *cmd, char **argv
+
+ #if !defined WIN32
+ static void
+-parse_utsname(struct utsname *name, char *fmt, char *result, char *msg)
++parse_utsname(struct utsname *name, const char *fmt, char *result, const char *msg)
+ {
+ char buf[SYS_NMLN * 5 + 1];
+ char *ptr = buf;
+@@ -892,7 +868,7 @@ parse_utsname(struct utsname *name, char
+
+ /* Just in case... */
+ if (strlen(buf) >= sizeof(buf))
+- LogFatal("Buffer overflow parsing uname.", "");
++ LogFatal("Buffer overflow parsing uname.");
+
+ /* Parse the buffer. The sscanf() return value is rarely correct. */
+ *result = '\0';
+@@ -978,13 +954,23 @@ const char *libc_c=
+ static void
+ get_libc_version(FILE *inFile)
+ {
+- char aout[] = "/tmp/imakeXXXXXX";
++ char aout[4096], *tmpdir;
+ FILE *fp;
+ const char *format = "%s -o %s -x c -";
+ char *cc;
+ int len;
+ char *command;
+
++ /* If $TMPDIR is defined and has an acceptable length,
++ * use that as tmp dir, else use /tmp. That fixes
++ * problems with /tmp mounted "noexec".
++ */
++ if((tmpdir = getenv("TMPDIR")) != NULL && strlen(tmpdir) < (4096-13))
++ strcpy(aout, tmpdir);
++ else
++ strcpy(aout, "/tmp");
++ strcat(aout, "/imakeXXXXXX");
++
+ /* Pre-create temp file safely */
+ {
+ /* Linux + ELF has mkstemp() */
+@@ -1000,7 +986,8 @@ get_libc_version(FILE *inFile)
+ cc = "gcc";
+ len = strlen (aout) + strlen (format) + strlen (cc);
+ if (len < 128) len = 128;
+- command = alloca (len);
++ if((command = alloca (len)) == NULL)
++ abort();
+
+ if (snprintf (command , len, format, cc, aout) == len)
+ abort ();
+@@ -1015,12 +1002,16 @@ get_libc_version(FILE *inFile)
+ abort ();
+
+ while (fgets (command, len, fp))
+- fprintf (inFile, command);
++ fputs (command, inFile);
+
+ len = pclose (fp);
+ remove (aout);
+- if (len)
+- abort ();
++ if (len) {
++ /* handwave furiously */
++ printf("#define DefaultLinuxCLibMajorVersion 6\n");
++ printf("#define DefaultLinuxCLibMinorVersion 12\n");
++ printf("#define DefaultLinuxCLibTeenyVersion 0\n");
++ }
+ }
+ #endif
+
+@@ -1031,14 +1022,14 @@ get_stackprotector(FILE *inFile)
+ FILE *fp;
+ char *cc;
+ char command[1024], buf[1024];
+-
++
+ cc = getenv("CC");
+ if (cc == NULL) {
+ cc = "cc";
+ }
+ snprintf(command, sizeof(command), "%s -v 2>&1", cc);
+ fp = popen(command, "r");
+- if (fp == NULL)
++ if (fp == NULL)
+ abort();
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (strstr(buf, "propolice") != NULL) {
+@@ -1046,11 +1037,10 @@ get_stackprotector(FILE *inFile)
+ break;
+ }
+ }
+- if (pclose(fp))
+- abort();
++ pclose(fp);
+ }
+ #endif
+-
++
+
+ #if defined CROSSCOMPILE || defined linux || defined(__GLIBC__)
+ static void
+@@ -1058,9 +1048,9 @@ get_distrib(FILE *inFile)
+ {
+ struct stat sb;
+
+- static char* suse = "/etc/SuSE-release";
+- static char* redhat = "/etc/redhat-release";
+- static char* debian = "/etc/debian_version";
++ static const char* suse = "/etc/SuSE-release";
++ static const char* redhat = "/etc/redhat-release";
++ static const char* debian = "/etc/debian_version";
+
+ fprintf (inFile, "%s\n", "#define LinuxUnknown 0");
+ fprintf (inFile, "%s\n", "#define LinuxSuSE 1");
+@@ -1076,14 +1066,14 @@ get_distrib(FILE *inFile)
+ fprintf (inFile, "%s\n", "#define LinuxWare 11");
+ fprintf (inFile, "%s\n", "#define LinuxYggdrasil 12");
+
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (CrossCompiling) {
+ fprintf (inFile, "%s\n",
+ "#define DefaultLinuxDistribution LinuxUnknown");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName Unknown");
+ return;
+ }
+-#endif
++# endif
+ if (lstat (suse, &sb) == 0) {
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistribution LinuxSuSE");
+ fprintf (inFile, "%s\n", "#define DefaultLinuxDistName SuSE");
+@@ -1116,7 +1106,7 @@ get_ld_version(FILE *inFile)
+ int ldmajor, ldminor;
+ const char *ld = "ld -v";
+
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (CrossCompiling) {
+ char cmd[PATH_MAX];
+ strcpy (cmd, CrossCompileDir);
+@@ -1124,7 +1114,7 @@ get_ld_version(FILE *inFile)
+ strcat (cmd,ld);
+ ldprog = popen (cmd, "r");
+ } else
+-#endif
++# endif
+ ldprog = popen (ld, "r");
+
+ if (ldprog) {
+@@ -1192,7 +1182,7 @@ get_binary_format(FILE *inFile)
+ * Returns: 0 if successful, -1 if not.
+ */
+ static int
+-ask_sun_compiler_for_versions(const char *cmd, const char *path,
++ask_sun_compiler_for_versions(const char *cmd, const char *path,
+ int *cmajor, int *cminor)
+ {
+ char buf[BUFSIZ];
+@@ -1201,7 +1191,7 @@ ask_sun_compiler_for_versions(const char
+ FILE* ccproc;
+ const char vflag[] = " -V 2>&1";
+ int retval = -1;
+-
++
+ int len = strlen(cmd) + sizeof(vflag);
+
+ if (path != NULL) {
+@@ -1229,7 +1219,7 @@ ask_sun_compiler_for_versions(const char
+ }
+ }
+ if (retval != 0) {
+- fprintf(stderr,
++ fprintf(stderr,
+ "warning: could not parse version number in output of:\n"
+ " %s\n", cmdtorun);
+ }
+@@ -1247,23 +1237,22 @@ get_sun_compiler_versions (FILE *inFile)
+ {
+ const char* sunpro_path = "/opt/SUNWspro/bin";
+ int cmajor, cminor, found = 0;
+- struct stat sb;
+
+ /* If cross-compiling, only check CrossCompilerDir for compilers.
+- * If not cross-compiling, first check cc in users $PATH,
++ * If not cross-compiling, first check cc in users $PATH,
+ * then try /opt/SUNWspro if not found in the users $PATH
+ */
+
+-#if defined CROSSCOMPILE
++# if defined CROSSCOMPILE
+ if (CrossCompiling) {
+ if (ask_sun_compiler_for_versions("cc", CrossCompileDir,
+ &cmajor, &cminor) == 0) {
+ found = 1;
+ }
+- }
++ }
+ else
+-#endif
+- {
++# endif
++ {
+ if (ask_sun_compiler_for_versions("cc", NULL, &cmajor, &cminor) == 0) {
+ found = 1;
+ } else if (ask_sun_compiler_for_versions("cc", sunpro_path,
+@@ -1282,22 +1271,22 @@ get_sun_compiler_versions (FILE *inFile)
+
+ /* Now do it again for C++ compiler (CC) */
+ found = 0;
+-#if defined CROSSCOMPILE
++# if defined CROSSCOMPILE
+ if (CrossCompiling) {
+ if (ask_sun_compiler_for_versions("CC", CrossCompileDir,
+ &cmajor, &cminor) == 0) {
+ found = 1;
+ }
+- }
++ }
+ else
+-#endif
+- {
++# endif
++ {
+ if (ask_sun_compiler_for_versions("CC", NULL, &cmajor, &cminor) == 0) {
+ found = 1;
+ } else if (ask_sun_compiler_for_versions("CC", sunpro_path,
+ &cmajor, &cminor) == 0) {
+ found = 1;
+- fprintf(inFile,
++ fprintf(inFile,
+ "#define DefaultSunProCplusplusCompilerDir %s", sunpro_path);
+ }
+ }
+@@ -1318,7 +1307,7 @@ static void
+ get_gcc_version(FILE *inFile, char *name)
+ {
+ fprintf (inFile, "#define HasGcc 1\n");
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (CrossCompiling)
+ {
+ if (gnu_c > 1) {
+@@ -1329,20 +1318,20 @@ get_gcc_version(FILE *inFile, char *name
+ fprintf (inFile, "#define GccMajorVersion %d\n", gnu_c);
+ fprintf (inFile, "#define GccMinorVersion %d\n", gnu_c_minor);
+ } else
+-#endif
++# endif
+ {
+-#if __GNUC__ > 1
++# if __GNUC__ > 1
+ fprintf (inFile, "#define HasGcc2 1\n");
+-# if __GNUC__ > 2
++# if __GNUC__ > 2
+ fprintf (inFile, "#define HasGcc3 1\n");
++# endif
+ # endif
+-#endif
+ fprintf (inFile, "#define GccMajorVersion %d\n", __GNUC__);
+ fprintf (inFile, "#define GccMinorVersion %d\n", __GNUC_MINOR__);
+ }
+-#if defined(HAS_MERGE_CONSTANTS)
++# if defined(HAS_MERGE_CONSTANTS)
+ fprintf (inFile, "#define HasGccMergeConstants %d\n", HAS_MERGE_CONSTANTS);
+-#endif
++# endif
+ }
+ #endif
+
+@@ -1350,8 +1339,8 @@ static boolean
+ get_gcc(char *cmd)
+ {
+ struct stat sb;
+- static char* gcc_path[] = {
+-# if defined(linux) || \
++ static const char* gcc_path[] = {
++#if defined(linux) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || \
+@@ -1362,14 +1351,14 @@ get_gcc(char *cmd)
+ defined(__GNU__) || \
+ defined(__GLIBC__)
+ "/usr/bin/cc", /* for Linux PostIncDir */
+-# endif
++#endif
+ "/usr/local/bin/gcc",
+ "/opt/gnu/bin/gcc",
+ "/usr/pkg/bin/gcc"
+ };
+
+ #ifdef CROSSCOMPILE
+- static char* cross_cc_name[] = {
++ static const char* cross_cc_name[] = {
+ "cc",
+ "gcc"
+ };
+@@ -1399,7 +1388,7 @@ get_gcc(char *cmd)
+ return FALSE;
+ }
+
+-#if defined CROSSCOMPILE || !defined __UNIXOS2__
++#ifdef CROSSCOMPILE
+ static void
+ get_gcc_incdir(FILE *inFile, char* name)
+ {
+@@ -1428,14 +1417,14 @@ get_gcc_incdir(FILE *inFile, char* name)
+ boolean
+ define_os_defaults(FILE *inFile)
+ {
+-#if defined CROSSCOMPILE || ( !defined(WIN32) && !defined(__UNIXOS2__) )
+-#ifdef CROSSCOMPILE
+-#ifdef __GNUC__
++#if defined CROSSCOMPILE || !defined(WIN32)
++# ifdef CROSSCOMPILE
++# ifdef __GNUC__
+ if (1)
+-#else
++# else
+ if ((sys != win32) && (sys != emx))
+-#endif
+-#endif
++# endif
++# endif
+ {
+ # if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
+ defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
+@@ -1444,16 +1433,16 @@ define_os_defaults(FILE *inFile)
+ char buf[SYS_NMLN * 5 + 1];
+
+ /* Obtain the system information. */
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (!CrossCompiling)
+-#endif
++# endif
+ {
+ if (uname(&uts_name) < 0)
+- LogFatal("Cannot invoke uname", "");
++ LogFatal("Cannot invoke uname");
+ else
+ name = &uts_name;
+ }
+-#if defined CROSSCOMPILE && (defined linux || defined(__GLIBC__))
++# if defined CROSSCOMPILE && (defined linux || defined(__GLIBC__))
+ else {
+ strncpy(uts_name.sysname,cross_uts_sysname,SYS_NMLN);
+ strncpy(uts_name.release,cross_uts_release,SYS_NMLN);
+@@ -1461,14 +1450,14 @@ define_os_defaults(FILE *inFile)
+ strncpy(uts_name.machine,cross_uts_machine,SYS_NMLN);
+ name = &uts_name;
+ }
+-#endif
+-# ifdef __FreeBSD__
++# endif
++# ifdef __FreeBSD__
+ /* Override for compiling in chroot of other OS version, such as
+ * in the bento build cluster.
+ */
+ {
+ char *e;
+- if ((e = getenv("OSREL")) != NULL &&
++ if ((e = getenv("OSREL")) != NULL &&
+ strlen(name->sysname) + strlen(e) + 1 < SYS_NMLN) {
+ strcpy(name->release, e);
+ strcpy(name->version, name->sysname);
+@@ -1476,7 +1465,7 @@ define_os_defaults(FILE *inFile)
+ strcat(name->version, e);
+ }
+ }
+-# endif
++# endif
+
+ # if defined DEFAULT_OS_NAME
+ # if defined CROSSCOMPILE
+@@ -1648,10 +1637,8 @@ define_os_defaults(FILE *inFile)
+ char name[PATH_MAX];
+ if (get_gcc(name)) {
+ get_gcc_version (inFile,name);
+-# if defined CROSSCOMPILE || !defined __UNIXOS2__
+-# if defined CROSSCOMPILE
++# if defined CROSSCOMPILE
+ if (sys != emx)
+-# endif
+ get_gcc_incdir(inFile,name);
+ # endif
+ }
+@@ -1664,7 +1651,7 @@ define_os_defaults(FILE *inFile)
+ get_binary_format(inFile);
+ # endif
+ }
+-#endif /* !WIN32 && !__UNIXOS2__*/
++#endif /* !WIN32 */
+ #if defined WIN32
+ # ifdef CROSSCOMPILE
+ else if (sys == win32 && !CrossCompiling)
+@@ -1688,8 +1675,6 @@ define_os_defaults(FILE *inFile)
+ #endif /* WIN32 */
+ #ifdef CROSSCOMPILE
+ else if (sys == emx)
+-#endif
+-#if defined CROSSCOMPILE || defined __UNIXOS2__
+ {
+ fprintf(inFile, "#define DefaultOSMajorVersion 4\n");
+ fprintf(inFile, "#define DefaultOSMinorVersion 0\n");
+@@ -1703,8 +1688,8 @@ define_os_defaults(FILE *inFile)
+ }
+
+ void
+-cppit(char *imakefile, char *template, char *masterc,
+- FILE *outfd, char *outfname)
++cppit(const char *imakefile, const char *template, const char *masterc,
++ FILE *outfd, const char *outfname)
+ {
+ FILE *inFile;
+
+@@ -1721,8 +1706,11 @@ cppit(char *imakefile, char *template, c
+ fprintf(inFile, IncludeFmt, ImakeTmplSym) < 0 ||
+ optional_include(inFile, "IMAKE_ADMIN_MACROS", "adminmacros") ||
+ optional_include(inFile, "IMAKE_LOCAL_MACROS", "localmacros") ||
+- fflush(inFile) ||
+- fclose(inFile))
++ fflush(inFile)) {
++ fclose(inFile);
++ LogFatal("Cannot write to %s.", masterc);
++ }
++ else if (fclose(inFile))
+ LogFatal("Cannot write to %s.", masterc);
+ /*
+ * Fork and exec cpp
+@@ -1737,8 +1725,8 @@ makeit(void)
+ doit(NULL, make_argv[0], make_argv);
+ }
+
+-char *
+-CleanCppInput(char *imakefile)
++const char *
++CleanCppInput(const char *imakefile)
+ {
+ FILE *outFile = NULL;
+ FILE *inFile;
+@@ -1792,28 +1780,29 @@ CleanCppInput(char *imakefile)
+ strcmp(ptoken, "pragma") &&
+ strcmp(ptoken, "undef")) {
+ if (outFile == NULL) {
+-#ifdef HAS_MKSTEMP
++#ifdef HAVE_MKSTEMP
+ int fd;
+ #endif
+- tmpImakefile = Strdup(tmpImakefile);
+-#ifndef HAS_MKSTEMP
+- if (mktemp(tmpImakefile) == NULL ||
+- (outFile = fopen(tmpImakefile, "w+")) == NULL) {
++ char *tmpImakefileName = Strdup(tmpImakefileTemplate);
++#ifndef HAVE_MKSTEMP
++ if (mktemp(tmpImakefileName) == NULL ||
++ (outFile = fopen(tmpImakefileName, "w+")) == NULL) {
+ LogFatal("Cannot open %s for write.",
+- tmpImakefile);
++ tmpImakefileName);
+ }
+ #else
+- fd=mkstemp(tmpImakefile);
++ fd=mkstemp(tmpImakefileName);
+ if (fd != -1)
+ outFile = fdopen(fd, "w");
+ if (outFile == NULL) {
+ if (fd != -1) {
+- unlink(tmpImakefile); close(fd);
++ unlink(tmpImakefileName); close(fd);
+ }
+ LogFatal("Cannot open %s for write.",
+- tmpImakefile);
++ tmpImakefileName);
+ }
+ #endif
++ tmpImakefile = tmpImakefileName;
+ }
+ writetmpfile(outFile, punwritten, pbuf-punwritten,
+ tmpImakefile);
+@@ -1838,7 +1827,7 @@ CleanCppInput(char *imakefile)
+ }
+
+ void
+-CleanCppOutput(FILE *tmpfd, char *tmpfname)
++CleanCppOutput(FILE *tmpfd, const char *tmpfname)
+ {
+ char *input;
+ int blankline = 0;
+@@ -1960,7 +1949,7 @@ isempty(char *line)
+
+ /*ARGSUSED*/
+ char *
+-ReadLine(FILE *tmpfd, char *tmpfname)
++ReadLine(FILE *tmpfd, const char *tmpfname)
+ {
+ static boolean initialized = FALSE;
+ static char *buf, *pline, *end;
+@@ -1988,10 +1977,10 @@ ReadLine(FILE *tmpfd, char *tmpfname)
+ fseek(tmpfd, 0, 0);
+ #if defined(SYSV) || defined(WIN32) || defined(USE_FREOPEN)
+ tmpfd = freopen(tmpfname, "w+", tmpfd);
+-#ifdef WIN32
++# ifdef WIN32
+ if (! tmpfd) /* if failed try again */
+ tmpfd = freopen(tmpfname, "w+", fp);
+-#endif
++# endif
+ if (! tmpfd)
+ LogFatal("cannot reopen %s\n", tmpfname);
+ #else /* !SYSV */
+@@ -1999,8 +1988,6 @@ ReadLine(FILE *tmpfd, char *tmpfname)
+ #endif /* !SYSV */
+ initialized = TRUE;
+ fprintf (tmpfd, "# Makefile generated by imake - do not edit!\n");
+- fprintf (tmpfd, "# %s\n",
+- "$Xorg: imake.c,v 1.6 2001/02/09 02:03:15 xorgcvs Exp $");
+ }
+
+ for (p1 = pline; p1 < end; p1++) {
+@@ -2036,7 +2023,7 @@ ReadLine(FILE *tmpfd, char *tmpfname)
+ }
+
+ void
+-writetmpfile(FILE *fd, char *buf, int cnt, char *fname)
++writetmpfile(FILE *fd, const char *buf, int cnt, const char *fname)
+ {
+ if (fwrite(buf, sizeof(char), cnt, fd) == -1)
+ LogFatal("Cannot write to %s.", fname);
+@@ -2048,7 +2035,7 @@ Emalloc(int size)
+ char *p;
+
+ if ((p = malloc(size)) == NULL)
+- LogFatalI("Cannot allocate %d bytes", size);
++ LogFatal("Cannot allocate %d bytes", size);
+ return(p);
+ }
+
+@@ -2066,10 +2053,10 @@ KludgeOutputLine(char **pline)
+ break;
+ case ' ': /*May need a tab*/
+ default:
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (inline_syntax)
+-#endif
+-#if defined CROSSCOMPILE || defined INLINE_SYNTAX
++# endif
++# if defined CROSSCOMPILE || defined INLINE_SYNTAX
+ {
+ if (*p == '<' && p[1] == '<') { /* inline file close */
+ InInline--;
+@@ -2077,7 +2064,7 @@ KludgeOutputLine(char **pline)
+ break;
+ }
+ }
+-#endif
++# endif
+ /*
+ * The following cases should not be treated as beginning of
+ * rules:
+@@ -2116,26 +2103,26 @@ KludgeOutputLine(char **pline)
+ quotechar = ']';
+ break;
+ case '=':
+-#ifdef CROSSCOMPILE
++# ifdef CROSSCOMPILE
+ if (remove_cpp_leadspace)
+-#endif
+-#if defined CROSSCOMPILE || defined REMOVE_CPP_LEADSPACE
++# endif
++# if defined CROSSCOMPILE || defined REMOVE_CPP_LEADSPACE
+ {
+ if (!InRule && **pline == ' ') {
+ while (**pline == ' ')
+ (*pline)++;
+ }
+ }
+-#endif
++# endif
+ goto breakfor;
+-#if defined CROSSCOMPILE || defined INLINE_SYNTAX
++# if defined CROSSCOMPILE || defined INLINE_SYNTAX
+ case '<':
+ if (inline_syntax) {
+ if (p[1] == '<') /* inline file start */
+ InInline++;
+ }
+ break;
+-#endif
++# endif
+ case ':':
+ if (p[1] == '=')
+ goto breakfor;
+@@ -2159,7 +2146,7 @@ KludgeResetRule(void)
+ }
+ #endif
+ char *
+-Strdup(char *cp)
++Strdup(const char *cp)
+ {
+ char *new = Emalloc(strlen(cp) + 1);
+
diff --git a/debian/patches/series b/debian/patches/series
index 9888e56f0..88b9a3058 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -28,6 +28,7 @@
052_nxcomp_macos10-nxauth-location.full+lite.patch
053_nx-X11_no-xcomp1-install-target.full.patch
054_nx-X11_ppc64-ftbfs.full.patch
+055_nx-X11_imake-Werror-format-security.full.patch
101_nxagent_set-rgb-path.full.patch
102_xserver-xext_set-securitypolicy-path.full.patch
103_nxagent_set-X0-config-path.full.patch