head 1.3; access; symbols pkgsrc-2013Q2:1.3.0.16 pkgsrc-2013Q2-base:1.3 pkgsrc-2012Q4:1.3.0.14 pkgsrc-2012Q4-base:1.3 pkgsrc-2011Q4:1.3.0.12 pkgsrc-2011Q4-base:1.3 pkgsrc-2011Q2:1.3.0.10 pkgsrc-2011Q2-base:1.3 pkgsrc-2009Q4:1.3.0.8 pkgsrc-2009Q4-base:1.3 pkgsrc-2008Q4:1.3.0.6 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.4 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.2 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.2.0.24 pkgsrc-2008Q2-base:1.2 cwrapper:1.2.0.22 pkgsrc-2008Q1:1.2.0.20 pkgsrc-2008Q1-base:1.2 pkgsrc-2007Q4:1.2.0.18 pkgsrc-2007Q4-base:1.2 pkgsrc-2007Q3:1.2.0.16 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.2.0.14 pkgsrc-2007Q2-base:1.2 pkgsrc-2007Q1:1.2.0.12 pkgsrc-2007Q1-base:1.2 pkgsrc-2006Q4:1.2.0.10 pkgsrc-2006Q4-base:1.2 pkgsrc-2006Q3:1.2.0.8 pkgsrc-2006Q3-base:1.2 pkgsrc-2006Q2:1.2.0.6 pkgsrc-2006Q2-base:1.2 pkgsrc-2006Q1:1.2.0.4 pkgsrc-2006Q1-base:1.2 pkgsrc-2005Q4:1.2.0.2 pkgsrc-2005Q4-base:1.2 pkgsrc-2005Q3:1.1.0.8 pkgsrc-2005Q3-base:1.1 pkgsrc-2005Q2:1.1.0.6 pkgsrc-2005Q2-base:1.1 pkgsrc-2005Q1:1.1.0.4 pkgsrc-2005Q1-base:1.1 pkgsrc-2004Q4:1.1.0.2 pkgsrc-2004Q4-base:1.1; locks; strict; comment @# @; 1.3 date 2008.07.14.23.01.32; author christos; state dead; branches; next 1.2; 1.2 date 2005.12.12.19.55.41; author joerg; state Exp; branches; next 1.1; 1.1 date 2004.12.18.00.39.31; author tron; state Exp; branches; next ; desc @@ 1.3 log @update to openmotif 2.3.1 @ text @$NetBSD: patch-bh,v 1.2 2005/12/12 19:55:41 joerg Exp $ --- lib/Xm/Xpmparse.c.orig 2000-04-28 16:05:21.000000000 +0100 +++ lib/Xm/Xpmparse.c 2004-12-18 00:31:35.000000000 +0000 @@@@ -47,6 +47,15 @@@@ #include "XpmI.h" #include +#define STRLCAT(dst, src, dstsize) { \ + if ((strlen(dst) + strlen(src)) < (dstsize)) \ + strcat(dst, src); \ + else return (XpmFileInvalid); } +#define STRLCPY(dst, src, dstsize) { \ + if (strlen(src) < (dstsize)) \ + strcpy(dst, src); \ + else return (XpmFileInvalid); } + LFUNC(ParsePixels, int, (xpmData *data, unsigned int width, unsigned int height, unsigned int ncolors, unsigned int cpp, XpmColor *colorTable, @@@@ -215,7 +224,7 @@@@ xpmParseValues(data, width, height, ncol unsigned int *extensions; { unsigned int l; - char buf[BUFSIZ]; + char buf[BUFSIZ+1]; if (!data->format) { /* XPM 2 or 3 */ @@@@ -324,10 +333,10 @@@@ xpmParseColors(data, ncolors, cpp, color XpmColor **colorTablePtr; xpmHashTable *hashtable; { - unsigned int key, l, a, b; + unsigned int key = 0, l, a, b, len; unsigned int curkey; /* current color key */ unsigned int lastwaskey; /* key read */ - char buf[BUFSIZ]; + char buf[BUFSIZ+1]; char curbuf[BUFSIZ]; /* current buffer */ char **sptr, *s; XpmColor *color; @@@@ -335,6 +344,8 @@@@ xpmParseColors(data, ncolors, cpp, color char **defaults; int ErrorStatus; + if (ncolors >= SIZE_MAX / sizeof(XpmColor)) + return (XpmNoMemory); colorTable = (XpmColor *) XpmCalloc(ncolors, sizeof(XpmColor)); if (!colorTable) return (XpmNoMemory); @@@@ -346,6 +357,10 @@@@ xpmParseColors(data, ncolors, cpp, color /* * read pixel value */ + if (cpp >= SIZE_MAX - 1) { + xpmFreeColorTable(colorTable, ncolors); + return (XpmNoMemory); + } color->string = (char *) XpmMalloc(cpp + 1); if (!color->string) { xpmFreeColorTable(colorTable, ncolors); @@@@ -383,13 +398,14 @@@@ xpmParseColors(data, ncolors, cpp, color } if (!lastwaskey && key < NKEYS) { /* open new key */ if (curkey) { /* flush string */ - s = (char *) XpmMalloc(strlen(curbuf) + 1); + len = strlen(curbuf) + 1; + s = (char *) XpmMalloc(len); if (!s) { xpmFreeColorTable(colorTable, ncolors); return (XpmNoMemory); } defaults[curkey] = s; - strcpy(s, curbuf); + memcpy(s, curbuf, len); } curkey = key + 1; /* set new key */ *curbuf = '\0'; /* reset curbuf */ @@@@ -400,9 +416,9 @@@@ xpmParseColors(data, ncolors, cpp, color return (XpmFileInvalid); } if (!lastwaskey) - strcat(curbuf, " "); /* append space */ + STRLCAT(curbuf, " ", sizeof(curbuf)); /* append space */ buf[l] = '\0'; - strcat(curbuf, buf);/* append buf */ + STRLCAT(curbuf, buf, sizeof(curbuf));/* append buf */ lastwaskey = 0; } } @@@@ -410,12 +426,13 @@@@ xpmParseColors(data, ncolors, cpp, color xpmFreeColorTable(colorTable, ncolors); return (XpmFileInvalid); } - s = defaults[curkey] = (char *) XpmMalloc(strlen(curbuf) + 1); + len = strlen(curbuf) + 1; + s = defaults[curkey] = (char *) XpmMalloc(len); if (!s) { xpmFreeColorTable(colorTable, ncolors); return (XpmNoMemory); } - strcpy(s, curbuf); + memcpy(s, curbuf, len); } } else { /* XPM 1 */ /* get to the beginning of the first string */ @@@@ -428,6 +445,10 @@@@ xpmParseColors(data, ncolors, cpp, color /* * read pixel value */ + if (cpp >= SIZE_MAX - 1) { + xpmFreeColorTable(colorTable, ncolors); + return (XpmNoMemory); + } color->string = (char *) XpmMalloc(cpp + 1); if (!color->string) { xpmFreeColorTable(colorTable, ncolors); @@@@ -456,16 +477,17 @@@@ xpmParseColors(data, ncolors, cpp, color *curbuf = '\0'; /* init curbuf */ while ((l = xpmNextWord(data, buf, BUFSIZ))) { if (*curbuf != '\0') - strcat(curbuf, " ");/* append space */ + STRLCAT(curbuf, " ", sizeof(curbuf));/* append space */ buf[l] = '\0'; - strcat(curbuf, buf); /* append buf */ + STRLCAT(curbuf, buf, sizeof(curbuf)); /* append buf */ } - s = (char *) XpmMalloc(strlen(curbuf) + 1); + len = strlen(curbuf) + 1; + s = (char *) XpmMalloc(len); if (!s) { xpmFreeColorTable(colorTable, ncolors); return (XpmNoMemory); } - strcpy(s, curbuf); + memcpy(s, curbuf, len); color->c_color = s; *curbuf = '\0'; /* reset curbuf */ if (a < ncolors - 1) @@@@ -490,6 +512,9 @@@@ ParsePixels(data, width, height, ncolors unsigned int *iptr, *iptr2; unsigned int a, x, y; + if ((height > 0 && width >= SIZE_MAX / height) || + width * height >= SIZE_MAX / sizeof(unsigned int)) + return XpmNoMemory; #ifndef FOR_MSW iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height); #else @@@@ -513,6 +538,9 @@@@ ParsePixels(data, width, height, ncolors { unsigned short colidx[256]; + if (ncolors > 256) + return (XpmFileInvalid); + bzero((char *)colidx, 256 * sizeof(short)); for (a = 0; a < ncolors; a++) colidx[(unsigned char)colorTable[a].string[0]] = a + 1; @@@@ -590,6 +618,9 @@@@ if (cidx[f]) XpmFree(cidx[f]);} char *s; char buf[BUFSIZ]; + if (cpp >= sizeof(buf)) + return (XpmFileInvalid); + buf[cpp] = '\0'; if (USE_HASHTABLE) { xpmHashAtom *slot; @ 1.2 log @Update OpenMotif to 2.2.3. Too many changes to list here, but most importantly no more imake usage. @ text @d1 1 a1 1 $NetBSD: patch-bh,v 1.1 2004/12/18 00:39:31 tron Exp $ @ 1.1 log @Fix vulnerabilities reported in CAN-2004-0687 and CAN-2004-0688 by applying a patch based on ICS's patch for OpenMotif 2.2.3. @ text @d1 1 a1 1 $NetBSD$ d5 1 a5 1 @@@@ -42,6 +42,15 @@@@ d21 1 a21 1 @@@@ -209,7 +218,7 @@@@ d30 1 a30 1 @@@@ -318,10 +327,10 @@@@ d43 1 a43 1 @@@@ -329,6 +338,8 @@@@ d52 1 a52 1 @@@@ -340,6 +351,10 @@@@ d63 1 a63 1 @@@@ -377,13 +392,14 @@@@ d80 1 a80 1 @@@@ -394,9 +410,9 @@@@ d92 1 a92 1 @@@@ -404,12 +420,13 @@@@ d108 1 a108 1 @@@@ -422,6 +439,10 @@@@ d119 1 a119 1 @@@@ -450,16 +471,17 @@@@ d121 1 a121 1 while (l = xpmNextWord(data, buf, BUFSIZ)) { d124 1 a124 1 + STRLCAT(curbuf, " ", sizeof(curbuf));/* append space */ d127 1 a127 1 + STRLCAT(curbuf, buf, sizeof(curbuf)); /* append buf */ d130 2 a131 2 + len = strlen(curbuf) + 1; + s = (char *) XpmMalloc(len); d137 1 a137 1 + memcpy(s, curbuf, len); d141 1 a141 1 @@@@ -484,6 +506,9 @@@@ d151 1 a151 1 @@@@ -507,6 +532,9 @@@@ d161 1 a161 1 @@@@ -584,6 +612,9 @@@@ @