Author: dnusinow
Date: 2005-05-15 13:03:38 -0500 (Sun, 15 May 2005)
New Revision: 2259

Added:
   trunk/debian/patches/099za_libxpm_spopen_fix.diff
Modified:
   trunk/debian/changelog
Log:
- Backport libxpm from X.org stable release (099za_libxpm_spopen_fix.diff)
- Open changelog entry for -14 release


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2005-05-13 19:46:51 UTC (rev 2258)
+++ trunk/debian/changelog      2005-05-15 18:03:38 UTC (rev 2259)
@@ -1,3 +1,14 @@
+xfree86 (4.3.0.dfsg.1-14) UNRELEASED; urgency=high
+
+  Urgency set to high due to security fix #308783
+
+  Changes by David Nusinow:
+
+  * Backport libxpm from X.org stable release (099za_libxpm_spopen_fix.diff).
+    (Closes: #308783)
+
+ -- David Nusinow <[EMAIL PROTECTED]>  Sun, 15 May 2005 13:51:22 -0400
+
 xfree86 (4.3.0.dfsg.1-13) unstable; urgency=high
 
   Urgency set to high due to fix for security flaw CAN-2005-0605 (see below).

Added: trunk/debian/patches/099za_libxpm_spopen_fix.diff
===================================================================
--- trunk/debian/patches/099za_libxpm_spopen_fix.diff   2005-05-13 19:46:51 UTC 
(rev 2258)
+++ trunk/debian/patches/099za_libxpm_spopen_fix.diff   2005-05-15 18:03:38 UTC 
(rev 2259)
@@ -0,0 +1,837 @@
+diff -ruN xc-old/extras/Xpm/cxpm/cxpm.c xc/extras/Xpm/cxpm/cxpm.c
+--- xc-old/extras/Xpm/cxpm/cxpm.c      2001-07-31 20:44:34.000000000 -0400
++++ xc/extras/Xpm/cxpm/cxpm.c  2005-05-14 16:16:52.000000000 -0400
+@@ -47,8 +47,9 @@
+  * note that 's' could stand both for "special" and "slow" ;-)
+  */
+ static int
+-sGetc(data)
++sGetc(data, file)
+     xpmData *data;
++    FILE *file;
+ {
+     int c = getc(data->stream.file);
+     if (c == '\n') {
+@@ -61,9 +62,10 @@
+ }
+ 
+ static void
+-sUngetc(data, c)
++sUngetc(data, c, file)
+     xpmData *data;
+     int c;
++    FILE *file;
+ {
+     ungetc(c, data->stream.file);
+     if (c == '\n') {
+diff -ruN xc-old/extras/Xpm/lib/Attrib.c xc/extras/Xpm/lib/Attrib.c
+--- xc-old/extras/Xpm/lib/Attrib.c     2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/Attrib.c 2005-05-14 16:16:52.000000000 -0400
+@@ -54,7 +54,7 @@
+     XpmColor **colorTable, **color;
+     unsigned int a;
+ 
+-    if (ncolors >= UINT_MAX / sizeof(XpmColor *))
++    if (ncolors >= UINT_MAX / sizeof(XpmColor *)) 
+       return XpmNoMemory;
+ 
+     colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
+diff -ruN xc-old/extras/Xpm/lib/CrBufFrI.c xc/extras/Xpm/lib/CrBufFrI.c
+--- xc-old/extras/Xpm/lib/CrBufFrI.c   2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/CrBufFrI.c       2005-05-14 16:16:52.000000000 -0400
+@@ -34,7 +34,7 @@
+ 
+ /* October 2004, source code review by Thomas Biege <[EMAIL PROTECTED]> */
+ 
+-/* $XFree86: xc/extras/Xpm/lib/CrBufFrI.c,v 1.2 2001/10/28 03:32:09 tsi Exp $ 
*/
++/* $XFree86$ */
+ 
+ #include "XpmI.h"
+ 
+diff -ruN xc-old/extras/Xpm/lib/CrDatFrI.c xc/extras/Xpm/lib/CrDatFrI.c
+--- xc-old/extras/Xpm/lib/CrDatFrI.c   2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/CrDatFrI.c       2005-05-14 16:16:52.000000000 -0400
+@@ -31,7 +31,7 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/CrDatFrI.c,v 1.2 2001/10/28 03:32:09 tsi Exp $ 
*/
++/* $XFree86$ */
+ 
+ /* October 2004, source code review by Thomas Biege <[EMAIL PROTECTED]> */
+ 
+diff -ruN xc-old/extras/Xpm/lib/create.c xc/extras/Xpm/lib/create.c
+--- xc-old/extras/Xpm/lib/create.c     2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/create.c 2005-05-14 16:16:52.000000000 -0400
+@@ -1,4 +1,4 @@
+-/* $XdotOrg: pre-CVS proposed fix for CESA-2004-003 alanc 7/25/2004 $ */
++/* $XdotOrg: xc/extras/Xpm/lib/create.c,v 1.2.4.2 2004/12/17 01:09:36 gisburn 
Exp $ */
+ /*
+  * Copyright (C) 1989-95 GROUPE BULL
+  *
+@@ -33,7 +33,7 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/create.c,v 1.3 2002/01/07 19:40:49 dawes Exp $ 
*/
++/* $XFree86: xc/extras/Xpm/lib/create.c,v 1.4 2003/05/27 22:26:20 tsi Exp $ */
+ 
+ /*
+  * The code related to FOR_MSW has been added by
+@@ -129,7 +129,9 @@
+ 
+ LFUNC(PutPixel1, int, (XImage *ximage, int x, int y, unsigned long pixel));
+ LFUNC(PutPixel, int, (XImage *ximage, int x, int y, unsigned long pixel));
++#if !defined(WORD64) && !defined(LONG64)
+ LFUNC(PutPixel32, int, (XImage *ximage, int x, int y, unsigned long pixel));
++#endif
+ LFUNC(PutPixel32MSB, int, (XImage *ximage, int x, int y, unsigned long 
pixel));
+ LFUNC(PutPixel32LSB, int, (XImage *ximage, int x, int y, unsigned long 
pixel));
+ LFUNC(PutPixel16MSB, int, (XImage *ximage, int x, int y, unsigned long 
pixel));
+@@ -770,7 +772,6 @@
+     unsigned int depth;
+     int bitmap_format;
+     XpmFreeColorsFunc freeColors;
+-    void *closure;
+ 
+     /* variables to return */
+     XImage *ximage = NULL;
+@@ -817,14 +818,10 @@
+       freeColors = attributes->free_colors;
+     else
+       freeColors = FreeColors;
+-    if (attributes && (attributes->valuemask & XpmColorClosure))
+-      closure = attributes->color_closure;
+-    else
+-      closure = NULL;
+ 
+     ErrorStatus = XpmSuccess;
+ 
+-    if (image->ncolors >= UINT_MAX / sizeof(Pixel))
++    if (image->ncolors >= UINT_MAX / sizeof(Pixel)) 
+       return (XpmNoMemory);
+ 
+     /* malloc pixels index tables */
+@@ -1218,10 +1215,10 @@
+     register char *src;
+     register char *dst;
+     register unsigned int *iptr;
+-    register unsigned int x, y, i;
++    register unsigned int x, y;
+     register char *data;
+     Pixel pixel, px;
+-    int nbytes, depth, ibu, ibpp;
++    int nbytes, depth, ibu, ibpp, i;
+ 
+     data = image->data;
+     iptr = pixelindex;
+@@ -1832,6 +1829,7 @@
+     return 1;
+ }
+ 
++#if !defined(WORD64) && !defined(LONG64)
+ static int
+ PutPixel32(ximage, x, y, pixel)
+     register XImage *ximage;
+@@ -1848,6 +1846,7 @@
+     *((unsigned long *)addr) = pixel;
+     return 1;
+ }
++#endif
+ 
+ static int
+ PutPixel32MSB(ximage, x, y, pixel)
+@@ -1995,7 +1994,6 @@
+     unsigned int depth;
+     int bitmap_format;
+     XpmFreeColorsFunc freeColors;
+-    void *closure;
+ 
+     /* variables to return */
+     XImage *ximage = NULL;
+@@ -2053,10 +2051,6 @@
+       freeColors = attributes->free_colors;
+     else
+       freeColors = FreeColors;
+-    if (attributes && (attributes->valuemask & XpmColorClosure))
+-      closure = attributes->color_closure;
+-    else
+-      closure = NULL;
+ 
+     cmts = info && (info->valuemask & XpmReturnComments);
+ 
+@@ -2105,7 +2099,7 @@
+       xpmGetCmt(data, &colors_cmt);
+ 
+     /* malloc pixels index tables */
+-    if (ncolors >= UINT_MAX / sizeof(Pixel))
++    if (ncolors >= UINT_MAX / sizeof(Pixel)) 
+       RETURN(XpmNoMemory);
+ 
+     image_pixels = (Pixel *) XpmMalloc(sizeof(Pixel) * ncolors);
+diff -ruN xc-old/extras/Xpm/lib/data.c xc/extras/Xpm/lib/data.c
+--- xc-old/extras/Xpm/lib/data.c       2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/data.c   2005-05-14 16:16:52.000000000 -0400
+@@ -31,7 +31,7 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/data.c,v 1.4 2002/01/07 19:40:49 dawes Exp $ */
++/* $XFree86: xc/extras/Xpm/lib/data.c,v 1.3 2001/10/28 03:32:10 tsi Exp $ */
+ 
+ /* October 2004, source code review by Thomas Biege <[EMAIL PROTECTED]> */
+ 
+diff -ruN xc-old/extras/Xpm/lib/hashtab.c xc/extras/Xpm/lib/hashtab.c
+--- xc-old/extras/Xpm/lib/hashtab.c    2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/hashtab.c        2005-05-14 16:16:52.000000000 -0400
+@@ -144,7 +144,7 @@
+     HASH_TABLE_GROWS
+       table->size = size;
+     table->limit = size / 3;
+-    if (size >= UINT_MAX / sizeof(*atomTable))
++    if (size >= UINT_MAX / sizeof(*atomTable)) 
+       return (XpmNoMemory);
+     atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable));
+     if (!atomTable)
+diff -ruN xc-old/extras/Xpm/lib/Imakefile xc/extras/Xpm/lib/Imakefile
+--- xc-old/extras/Xpm/lib/Imakefile    2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/Imakefile        2005-05-14 16:16:52.000000000 -0400
+@@ -104,15 +104,13 @@
+        CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \
+        CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \
+        CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \
+-       Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \
+-       s_popen.c
++       Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c
+ 
+   OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \
+        CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \
+        CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \
+        CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \
+-       Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \
+-       s_popen.o
++       Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o
+ 
+        INCLUDES = -I.
+        LINTLIBS = $(LINTXTOLL) $(LINTXLIB) 
+diff -ruN xc-old/extras/Xpm/lib/parse.c xc/extras/Xpm/lib/parse.c
+--- xc-old/extras/Xpm/lib/parse.c      2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/parse.c  2005-05-14 16:16:52.000000000 -0400
+@@ -1,4 +1,4 @@
+-/* $XdotOrg: pre-CVS proposed fix for CESA-2004-003 alanc 7/25/2004 $ */
++/* $XdotOrg: xc/extras/Xpm/lib/parse.c,v 1.2.4.2 2004/12/17 01:09:36 gisburn 
Exp $ */
+ /*
+  * Copyright (C) 1989-95 GROUPE BULL
+  *
+@@ -23,7 +23,7 @@
+  * used in advertising or otherwise to promote the sale, use or other dealings
+  * in this Software without prior written authorization from GROUPE BULL.
+  */
+-/* $XFree86: xc/extras/Xpm/lib/parse.c,v 1.3 2001/10/28 03:32:10 tsi Exp $ */
++/* $XFree86: xc/extras/Xpm/lib/parse.c,v 1.2 2000/09/26 15:56:43 tsi Exp $ */
+ 
+ 
/*****************************************************************************\
+ * parse.c:                                                                    
*
+@@ -34,7 +34,7 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/parse.c,v 1.3 2001/10/28 03:32:10 tsi Exp $ */
++/* $XFree86$ */
+ 
+ /*
+  * The code related to FOR_MSW has been added by
+@@ -376,7 +376,7 @@
+     unsigned int a, x, y;
+ 
+     if ((height > 0 && width >= UINT_MAX / height) ||
+-      width * height >= UINT_MAX / sizeof(unsigned int))
++      width * height >= UINT_MAX / sizeof(unsigned int)) 
+       return XpmNoMemory;
+ #ifndef FOR_MSW
+     iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height);
+diff -ruN xc-old/extras/Xpm/lib/RdFToI.c xc/extras/Xpm/lib/RdFToI.c
+--- xc-old/extras/Xpm/lib/RdFToI.c     2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/RdFToI.c 2005-05-14 16:16:52.000000000 -0400
+@@ -31,20 +31,16 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/RdFToI.c,v 1.2 2001/10/28 03:32:09 tsi Exp $ */
++/* $XFree86$ */
+ 
+ /* October 2004, source code review by Thomas Biege <[EMAIL PROTECTED]> */
+ 
+ #include "XpmI.h"
+-#include <sys/stat.h>
+-#if !defined(NO_ZPIPE) && defined(WIN32)
+-# define popen _popen
+-# define pclose _pclose
+-# if defined(STAT_ZFILE)
+-#  include <io.h>
+-#  define stat _stat
+-#  define fstat _fstat
+-# endif
++#ifndef NO_ZPIPE
++#include <fcntl.h>
++#include <errno.h>
++#include <sys/types.h>
++#include <sys/wait.h>
+ #endif
+ 
+ LFUNC(OpenReadFile, int, (char *filename, xpmData *mdata));
+@@ -122,89 +118,131 @@
+ }
+ #endif /* CXPMPROG */
+ 
+-/*
+- * open the given file to be read as an xpmData which is returned.
+- */
+ #ifndef NO_ZPIPE
+-      FILE *s_popen(char *cmd, const char *type);
+-#else
+-#     define s_popen popen
++/* Do not depend on errno after read_through */
++FILE*
++xpmPipeThrough(fd, cmd, arg1, mode)
++    int fd;
++    const char* cmd;
++    const char* arg1;
++    const char* mode;
++{
++    FILE* fp;
++    int status, fds[2], in = 0, out = 1;
++    pid_t pid;
++    if ( 'w' == *mode )
++      out = 0, in = 1;
++    if ( pipe(fds) < 0 )
++      return NULL;
++    pid = fork();
++    if ( pid < 0 )
++      goto fail1;
++    if ( 0 == pid )
++    {
++      close(fds[in]);
++      if ( dup2(fds[out], out) < 0 )
++          goto err;
++      close(fds[out]);
++      if ( dup2(fd, in) < 0 )
++          goto err;
++      close(fd);
++      pid = fork();
++      if ( pid < 0 )
++          goto err;
++      if ( 0 == pid )
++      {
++          execlp(cmd, cmd, arg1, NULL);
++          perror(cmd);
++          goto err;
++      }
++      _exit(0);
++    err:
++      _exit(1);
++    }
++    close(fds[out]);
++    /* calling process: wait for first child */
++    while ( waitpid(pid, &status, 0) < 0 && EINTR == errno )
++      ;
++    if ( WIFSIGNALED(status) ||
++       (WIFEXITED(status) && WEXITSTATUS(status) != 0) )
++      goto fail2;
++    fp = fdopen(fds[in], mode);
++    if ( !fp )
++      goto fail2;
++    close(fd); /* still open in 2nd child */
++    return fp;
++fail1:
++    close(fds[out]);
++fail2:
++    close(fds[in]);
++    return NULL;
++}
+ #endif
+ 
++/*
++ * open the given file to be read as an xpmData which is returned.
++ */
+ static int
+ OpenReadFile(filename, mdata)
+     char *filename;
+     xpmData *mdata;
+ {
+-#ifndef NO_ZPIPE
+-    char buf[BUFSIZ];
+-# ifdef STAT_ZFILE
+-    char *compressfile;
+-    struct stat status;
+-# endif
+-#endif
+-
+     if (!filename) {
+       mdata->stream.file = (stdin);
+       mdata->type = XPMFILE;
+     } else {
+-#ifndef NO_ZPIPE
+-      size_t len = strlen(filename);
+-
+-      if (len == 0)
+-              return(XpmOpenFailed);
+-      if ((len > 2) && !strcmp(".Z", filename + (len - 2))) {
+-          mdata->type = XPMPIPE;
+-          snprintf(buf, sizeof(buf), "uncompress -c \"%s\"", filename);
+-          if (!(mdata->stream.file = s_popen(buf, "r")))
+-              return (XpmOpenFailed);
+-
+-      } else if ((len > 3) && !strcmp(".gz", filename + (len - 3))) {
+-          mdata->type = XPMPIPE;
+-          snprintf(buf, sizeof(buf), "gunzip -qc \"%s\"", filename);
+-          if (!(mdata->stream.file = s_popen(buf, "r")))
+-              return (XpmOpenFailed);
+-
+-      } else {
+-# ifdef STAT_ZFILE
+-          if (!(compressfile = (char *) XpmMalloc(len + 4)))
++      int fd = open(filename, O_RDONLY);
++#if defined(NO_ZPIPE)
++      if ( fd < 0 )
++          return XpmOpenFailed;
++#else
++      const char* ext = NULL;
++      if ( fd >= 0 )
++          ext = strrchr(filename, '.');
++#ifdef STAT_ZFILE /* searching for z-files if the given name not found */
++      else
++      {
++          size_t len = strlen(filename);
++          char *compressfile = (char *) XpmMalloc(len + 4);
++          if ( !compressfile )
+               return (XpmNoMemory);
+-
+-          snprintf(compressfile, len+4, "%s.Z", filename);
+-          if (!stat(compressfile, &status)) {
+-              snprintf(buf, sizeof(buf), "uncompress -c \"%s\"", 
compressfile);
+-              if (!(mdata->stream.file = s_popen(buf, "r"))) {
++          strcpy(compressfile, filename);
++          strcpy(compressfile + len, ext = ".Z");
++          fd = open(compressfile, O_RDONLY);
++          if ( fd < 0 )
++          {
++              strcpy(compressfile + len, ext = ".gz");
++              fd = open(compressfile, O_RDONLY);
++              if ( fd < 0 )
++              {
+                   XpmFree(compressfile);
+-                  return (XpmOpenFailed);
+-              }
+-              mdata->type = XPMPIPE;
+-          } else {
+-              snprintf(compressfile, len+4, "%s.gz", filename);
+-              if (!stat(compressfile, &status)) {
+-                  snprintf(buf, sizeof(buf), "gunzip -c \"%s\"", 
compressfile);
+-                  if (!(mdata->stream.file = s_popen(buf, "r"))) {
+-                      XpmFree(compressfile);
+-                      return (XpmOpenFailed);
+-                  }
+-                  mdata->type = XPMPIPE;
+-              } else {
+-# endif
+-#endif
+-                  if (!(mdata->stream.file = fopen(filename, "r"))) {
+-#if !defined(NO_ZPIPE) && defined(STAT_ZFILE)
+-                      XpmFree(compressfile);
+-#endif
+-                      return (XpmOpenFailed);
+-                  }
+-                  mdata->type = XPMFILE;
+-#ifndef NO_ZPIPE
+-# ifdef STAT_ZFILE
++                  return XpmOpenFailed;
+               }
+           }
+           XpmFree(compressfile);
+-# endif
+       }
+ #endif
++      if ( ext && !strcmp(ext, ".Z") )
++      {
++          mdata->type = XPMPIPE;
++          mdata->stream.file = xpmPipeThrough(fd, "uncompress", "-c", "r");
++      }
++      else if ( ext && !strcmp(ext, ".gz") )
++      {
++          mdata->type = XPMPIPE;
++          mdata->stream.file = xpmPipeThrough(fd, "gunzip", "-qc", "r");
++      }
++      else
++#endif /* z-files */
++      {
++          mdata->type = XPMFILE;
++          mdata->stream.file = fdopen(fd, "r");
++      }
++      if (!mdata->stream.file)
++      {
++          close(fd);
++          return (XpmOpenFailed);
++      }
+     }
+     mdata->CommentLength = 0;
+ #ifdef CXPMPROG
+@@ -221,15 +259,6 @@
+ xpmDataClose(mdata)
+     xpmData *mdata;
+ {
+-    switch (mdata->type) {
+-    case XPMFILE:
+-      if (mdata->stream.file != (stdin))
+-          fclose(mdata->stream.file);
+-      break;
+-#ifndef NO_ZPIPE
+-    case XPMPIPE:
++    if (mdata->stream.file != (stdin))
+       fclose(mdata->stream.file);
+-      break;
+-#endif
+-    }
+ }
+diff -ruN xc-old/extras/Xpm/lib/scan.c xc/extras/Xpm/lib/scan.c
+--- xc-old/extras/Xpm/lib/scan.c       2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/scan.c   2005-05-14 16:16:52.000000000 -0400
+@@ -31,7 +31,7 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/scan.c,v 1.3 2002/01/07 19:40:49 dawes Exp $ */
++/* $XFree86: xc/extras/Xpm/lib/scan.c,v 1.2 2001/10/28 03:32:11 tsi Exp $ */
+ 
+ /*
+  * The code related to FOR_MSW has been added by
+@@ -109,8 +109,8 @@
+ LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp,
+                                 XpmAttributes *attributes));
+ 
+-LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors,
+-                           unsigned int ncolors,
++LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors, 
++                           unsigned int ncolors, 
+                            Pixel *pixels, unsigned int mask,
+                            unsigned int cpp, XpmAttributes *attributes));
+ 
+@@ -243,7 +243,7 @@
+     if (!pmap.pixelindex)
+       RETURN(XpmNoMemory);
+ 
+-    if (pmap.size >= UINT_MAX / sizeof(Pixel))
++    if (pmap.size >= UINT_MAX / sizeof(Pixel)) 
+       RETURN(XpmNoMemory);
+ 
+     pmap.pixels = (Pixel *) XpmMalloc(sizeof(Pixel) * pmap.size);
+@@ -621,8 +621,8 @@
+     char *dst;
+     unsigned int *iptr;
+     char *data;
+-    unsigned int x, y, i;
+-    int bits, depth, ibu, ibpp, offset;
++    unsigned int x, y;
++    int bits, depth, ibu, ibpp, offset, i;
+     unsigned long lbt;
+     Pixel pixel, px;
+ 
+@@ -633,6 +633,9 @@
+     ibpp = image->bits_per_pixel;
+     offset = image->xoffset;
+ 
++    if (image->bitmap_unit < 0)
++          return (XpmNoMemory);
++
+     if ((image->bits_per_pixel | image->depth) == 1) {
+       ibu = image->bitmap_unit;
+       for (y = 0; y < height; y++)
+diff -ruN xc-old/extras/Xpm/lib/WrFFrI.c xc/extras/Xpm/lib/WrFFrI.c
+--- xc-old/extras/Xpm/lib/WrFFrI.c     2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/WrFFrI.c 2005-05-14 16:16:52.000000000 -0400
+@@ -31,19 +31,21 @@
+ *                                                                             
*
+ *  Developed by Arnaud Le Hors                                                
*
+ 
\*****************************************************************************/
+-/* $XFree86: xc/extras/Xpm/lib/WrFFrI.c,v 1.2 2001/10/28 03:32:09 tsi Exp $ */
++/* $XFree86$ */
+ 
+ /*
+  * The code related to AMIGA has been added by
+  * Lorens Younes ([EMAIL PROTECTED]) 4/96
+  */
+ 
+-/* October 2004, source code review by Thomas Biege <[EMAIL PROTECTED]> */
+-
+ #include "XpmI.h"
+-#if !defined(NO_ZPIPE) && defined(WIN32)
+-# define popen _popen
+-# define pclose _pclose
++
++#ifndef NO_ZPIPE
++#include "sys/wait.h"
++#include "sys/types.h"
++#include "fcntl.h"
++#include "unistd.h"
++#include "errno.h"
+ #endif
+ 
+ /* MS Windows define a function called WriteFile @#%#&!!! */
+@@ -124,7 +126,7 @@
+       /* let's try to make a valid C syntax name */
+       if (index(name, '.')) {
+           strncpy(new_name, name, sizeof(new_name));
+-          new_name[sizeof(new_name)-1] = 0;
++          new_name[sizeof(new_name)-1] = '\0';
+           /* change '.' to '_' */
+           name = s = new_name;
+           while ((dot = index(s, '.'))) {
+@@ -134,8 +136,7 @@
+       }
+       if (index(name, '-')) {
+           if (name != new_name) {
+-              strncpy(new_name, name, sizeof(new_name));
+-              new_name[sizeof(new_name)-1] = 0;
++              strcpy(new_name, name);
+               name = new_name;
+           }
+           /* change '-' to '_' */
+@@ -252,8 +253,8 @@
+     unsigned int x, y, h;
+ 
+     h = height - 1;
+-    if (cpp != 0 && width >= (UINT_MAX - 3)/cpp)
+-      return XpmNoMemory;
++    if (cpp != 0 && width >= (UINT_MAX - 3)/cpp) 
++      return XpmNoMemory;    
+     p = buf = (char *) XpmMalloc(width * cpp + 3);
+     if (!buf)
+       return (XpmNoMemory);
+@@ -301,55 +302,48 @@
+     fprintf(file, ",\n\"XPMENDEXT\"");
+ }
+ 
++
++#ifndef NO_ZPIPE
++FUNC(xpmPipeThrough, FILE*, (int fd,
++                           const char* cmd,
++                           const char* arg1,
++                           const char* mode));
++#endif
++
+ /*
+  * open the given file to be written as an xpmData which is returned
+  */
+-#ifndef NO_ZPIPE
+-      FILE *s_popen(char *cmd, const char *type);
+-#else
+-#     define s_popen popen
+-#endif
+ static int
+ OpenWriteFile(filename, mdata)
+     char *filename;
+     xpmData *mdata;
+ {
+-#ifndef NO_ZPIPE
+-    char buf[BUFSIZ];
+-
+-#endif
+-
+     if (!filename) {
+       mdata->stream.file = (stdout);
+       mdata->type = XPMFILE;
+     } else {
+ #ifndef NO_ZPIPE
+-      size_t len = strlen(filename);
+-
+-      if (len == 0)
+-              return(XpmOpenFailed);
+-
++      size_t len;
++#endif
++      int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
++      if ( fd < 0 )
++          return(XpmOpenFailed);
++#ifndef NO_ZPIPE
++      len = strlen(filename);
+       if (len > 2 && !strcmp(".Z", filename + (len - 2))) {
+-          snprintf(buf, sizeof(buf), "compress > \"%s\"", filename);
+-          if (!(mdata->stream.file = s_popen(buf, "w")))
+-              return (XpmOpenFailed);
+-
++          mdata->stream.file = xpmPipeThrough(fd, "compress", NULL, "w");
+           mdata->type = XPMPIPE;
+       } else if (len > 3 && !strcmp(".gz", filename + (len - 3))) {
+-          snprintf(buf, sizeof(buf), "gzip -q > \"%s\"", filename);
+-          if (!(mdata->stream.file = s_popen(buf, "w")))
+-              return (XpmOpenFailed);
+-
++          mdata->stream.file = xpmPipeThrough(fd, "gzip", "-q", "w");
+           mdata->type = XPMPIPE;
+-      } else {
++      } else
+ #endif
+-          if (!(mdata->stream.file = fopen(filename, "w")))
+-              return (XpmOpenFailed);
+-
++      {
++          mdata->stream.file = fdopen(fd, "w");
+           mdata->type = XPMFILE;
+-#ifndef NO_ZPIPE
+       }
+-#endif
++      if (!mdata->stream.file)
++          return (XpmOpenFailed);
+     }
+     return (XpmSuccess);
+ }
+@@ -361,15 +355,7 @@
+ xpmDataClose(mdata)
+     xpmData *mdata;
+ {
+-    switch (mdata->type) {
+-    case XPMFILE:
+-      if (mdata->stream.file != (stdout))
+-          fclose(mdata->stream.file);
+-      break;
+-#ifndef NO_ZPIPE
+-    case XPMPIPE:
++    if (mdata->stream.file != (stdout))
+       fclose(mdata->stream.file);
+-      break;
+-#endif
+-    }
+ }
++
+diff -ruN xc-old/extras/Xpm/lib/xpm.h xc/extras/Xpm/lib/xpm.h
+--- xc-old/extras/Xpm/lib/xpm.h        2001-08-22 19:36:44.000000000 -0400
++++ xc/extras/Xpm/lib/xpm.h    2005-05-14 16:16:52.000000000 -0400
+@@ -85,16 +85,6 @@
+ # define PIXEL_ALREADY_TYPEDEFED
+ #endif
+ 
+-/* make sure we know whether function prototypes are needed or not */
+-#ifndef NeedFunctionPrototypes
+-# if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+-#  define NeedFunctionPrototypes 1
+-# else
+-#  define NeedFunctionPrototypes 0
+-# endif
+-#endif
+-
+-
+ /* Return ErrorStatus codes:
+  * null     if full success
+  * positive if partial success
+@@ -150,23 +140,19 @@
+ }      XpmInfo;
+ 
+ typedef int (*XpmAllocColorFunc)(
+-#if NeedFunctionPrototypes
+     Display*                  /* display */,
+     Colormap                  /* colormap */,
+     char*                     /* colorname */,
+     XColor*                   /* xcolor */,
+     void*                     /* closure */
+-#endif
+ );
+ 
+ typedef int (*XpmFreeColorsFunc)(
+-#if NeedFunctionPrototypes
+     Display*                  /* display */,
+     Colormap                  /* colormap */,
+     Pixel*                    /* pixels */,
+     int                               /* npixels */,
+     void*                     /* closure */
+-#endif
+ );
+ 
+ typedef struct {
+@@ -290,22 +276,15 @@
+ 
+ 
+ /* macros for forward declarations of functions with prototypes */
+-#if NeedFunctionPrototypes
+ #define FUNC(f, t, p) extern t f p
+ #define LFUNC(f, t, p) static t f p
+-#else
+-#define FUNC(f, t, p) extern t f()
+-#define LFUNC(f, t, p) static t f()
+-#endif
+ 
+ 
+ /*
+  * functions declarations
+  */
+ 
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
++_XFUNCPROTOBEGIN
+ 
+ /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
+ /* Same for Amiga! */
+@@ -459,10 +438,7 @@
+ 
+     FUNC(XpmFree, void, (void *ptr));
+ 
+-#ifdef __cplusplus
+-} /* for C++ V2.0 */
+-#endif
+-
++_XFUNCPROTOEND
+ 
+ /* backward compatibility */
+ 
+diff -ruN xc-old/extras/Xpm/lib/XpmI.h xc/extras/Xpm/lib/XpmI.h
+--- xc-old/extras/Xpm/lib/XpmI.h       2005-05-14 15:57:06.000000000 -0400
++++ xc/extras/Xpm/lib/XpmI.h   2005-05-14 16:16:52.000000000 -0400
+@@ -22,7 +22,7 @@
+  * used in advertising or otherwise to promote the sale, use or other dealings
+  * in this Software without prior written authorization from GROUPE BULL.
+  */
+-/* $XFree86: xc/extras/Xpm/lib/XpmI.h,v 1.8 2002/01/07 19:40:23 dawes Exp $ */
++/* $XFree86: xc/extras/Xpm/lib/XpmI.h,v 1.7 2001/11/01 23:35:25 dawes Exp $ */
+ 
+ 
/*****************************************************************************\
+ * XpmI.h:                                                                     
*
+@@ -60,6 +60,7 @@
+ 
+ #include <X11/Xos.h>
+ #include <X11/Xfuncs.h>
++#include <X11/Xmd.h>
+ 
+ #ifdef VMS
+ #include <unixio.h>
+@@ -94,7 +95,7 @@
+ #ifndef SIZE_MAX
+ # ifdef ULONG_MAX
+ #  define SIZE_MAX ULONG_MAX
+-# else
++# else 
+ #  define SIZE_MAX UINT_MAX
+ # endif
+ #endif
+diff -ruN xc-old/extras/Xpm/sxpm/sxpm.c xc/extras/Xpm/sxpm/sxpm.c
+--- xc-old/extras/Xpm/sxpm/sxpm.c      2001-10-27 23:32:13.000000000 -0400
++++ xc/extras/Xpm/sxpm/sxpm.c  2005-05-14 16:16:52.000000000 -0400
+@@ -22,7 +22,7 @@
+  * used in advertising or otherwise to promote the sale, use or other dealings
+  * in this Software without prior written authorization from GROUPE BULL.
+  */
+-/* $XFree86: xc/extras/Xpm/sxpm/sxpm.c,v 1.3 2001/10/28 03:32:13 tsi Exp $ */
++/* $XFree86: xc/extras/Xpm/sxpm/sxpm.c,v 1.2 2001/08/01 00:44:34 tsi Exp $ */
+ 
+ 
/*****************************************************************************\
+ * sxpm.c:                                                                     
*
+diff -ruN xc-old/extras/Xpm/sxpm/sxpm.man xc/extras/Xpm/sxpm/sxpm.man
+--- xc-old/extras/Xpm/sxpm/sxpm.man    2005-05-14 15:56:50.000000000 -0400
++++ xc/extras/Xpm/sxpm/sxpm.man        2005-05-14 16:16:52.000000000 -0400
+@@ -21,6 +21,7 @@
+ .\"used in advertising or otherwise to promote the sale, use or other dealings
+ .\"in this Software without prior written authorization from GROUPE BULL.
+ .\"
++.\" $XFree86$
+ .nr )S 12
+ .TH SXPM 1
+ .PD


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to