libxpm-3.5.12

This commit is contained in:
Anatol Belski
2017-03-19 13:06:12 +01:00
parent bf2d42cdff
commit 10a354f19e
7 changed files with 147 additions and 24 deletions

78
.gitignore vendored Normal file
View File

@@ -0,0 +1,78 @@
#
# X.Org module default exclusion patterns
# The next section if for module specific patterns
#
# Do not edit the following section
# GNU Build System (Autotools)
aclocal.m4
autom4te.cache/
autoscan.log
ChangeLog
compile
config.guess
config.h
config.h.in
config.log
config-ml.in
config.py
config.status
config.status.lineno
config.sub
configure
configure.scan
depcomp
.deps/
INSTALL
install-sh
.libs/
libtool
libtool.m4
ltmain.sh
lt~obsolete.m4
ltoptions.m4
ltsugar.m4
ltversion.m4
Makefile
Makefile.in
mdate-sh
missing
mkinstalldirs
*.pc
py-compile
stamp-h?
symlink-tree
texinfo.tex
ylwrap
# Do not edit the following section
# Edit Compile Debug Document Distribute
*~
*.[0-9]
*.[0-9]x
*.bak
*.bin
core
*.dll
*.exe
*-ISO*.bdf
*-JIS*.bdf
*-KOI8*.bdf
*.kld
*.ko
*.ko.cmd
*.lai
*.l[oa]
*.[oa]
*.obj
*.patch
*.so
*.pcf.gz
*.pdb
*.tar.bz2
*.tar.gz
#
# Add & Override patterns for libXpm
#
# Edit the following section as needed
# For example, !report.pc overrides *.pc. See 'man gitignore'
#

View File

@@ -1,7 +1,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([libXpm], [3.5.11],
AC_INIT([libXpm], [3.5.12],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXpm])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])

View File

@@ -48,7 +48,7 @@ LFUNC(CreatePixels, void, (char **dataptr, unsigned int data_size,
unsigned int height, unsigned int cpp,
unsigned int *pixels, XpmColor *colors));
LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num,
LFUNC(CountExtensions, int, (XpmExtension *ext, unsigned int num,
unsigned int *ext_size,
unsigned int *ext_nlines));
@@ -122,8 +122,9 @@ XpmCreateDataFromXpmImage(
/* compute the number of extensions lines and size */
if (extensions)
CountExtensions(info->extensions, info->nextensions,
&ext_size, &ext_nlines);
if (CountExtensions(info->extensions, info->nextensions,
&ext_size, &ext_nlines))
return(XpmNoMemory);
/*
* alloc a temporary array of char pointer for the header section which
@@ -187,7 +188,8 @@ XpmCreateDataFromXpmImage(
if(offset <= image->width || offset <= image->cpp)
RETURN(XpmNoMemory);
if( (image->height + ext_nlines) >= UINT_MAX / sizeof(char *))
if (image->height > UINT_MAX - ext_nlines ||
image->height + ext_nlines >= UINT_MAX / sizeof(char *))
RETURN(XpmNoMemory);
data_size = (image->height + ext_nlines) * sizeof(char *);
@@ -196,7 +198,8 @@ XpmCreateDataFromXpmImage(
RETURN(XpmNoMemory);
data_size += image->height * offset;
if( (header_size + ext_size) >= (UINT_MAX - data_size) )
if (header_size > UINT_MAX - ext_size ||
header_size + ext_size >= (UINT_MAX - data_size) )
RETURN(XpmNoMemory);
data_size += header_size + ext_size;
@@ -343,13 +346,14 @@ CreatePixels(
*s = '\0';
}
static void
static int
CountExtensions(
XpmExtension *ext,
unsigned int num,
unsigned int *ext_size,
unsigned int *ext_nlines)
{
size_t len;
unsigned int x, y, a, size, nlines;
char **line;
@@ -357,16 +361,28 @@ CountExtensions(
nlines = 0;
for (x = 0; x < num; x++, ext++) {
/* 1 for the name */
if (ext->nlines == UINT_MAX || nlines > UINT_MAX - ext->nlines - 1)
return (1);
nlines += ext->nlines + 1;
/* 8 = 7 (for "XPMEXT ") + 1 (for 0) */
size += strlen(ext->name) + 8;
len = strlen(ext->name) + 8;
if (len > UINT_MAX - size)
return (1);
size += len;
a = ext->nlines;
for (y = 0, line = ext->lines; y < a; y++, line++)
size += strlen(*line) + 1;
for (y = 0, line = ext->lines; y < a; y++, line++) {
len = strlen(*line) + 1;
if (len > UINT_MAX - size)
return (1);
size += len;
}
}
if (size > UINT_MAX - 10 || nlines > UINT_MAX - 1)
return (1);
/* 10 and 1 are for the ending "XPMENDEXT" */
*ext_size = size + 10;
*ext_nlines = nlines + 1;
return (0);
}
static void

View File

@@ -89,6 +89,10 @@ XpmReadFileToBuffer(
return XpmOpenFailed;
}
len = stats.st_size;
if (len < 0 || len >= SIZE_MAX) {
close(fd);
return XpmOpenFailed;
}
ptr = (char *) XpmMalloc(len + 1);
if (!ptr) {
fclose(fp);

View File

@@ -44,7 +44,7 @@ XpmWriteFileFromBuffer(
const char *filename,
char *buffer)
{
int fcheck, len;
size_t fcheck, len;
FILE *fp = fopen(filename, "w");
if (!fp)

View File

@@ -347,10 +347,10 @@ SetCloseColor(
closenesses[i].cols_index = i;
closenesses[i].closeness =
COLOR_FACTOR * (abs((long) col->red - (long) cols[i].red)
+ abs((long) col->green - (long) cols[i].green)
+ abs((long) col->blue - (long) cols[i].blue))
+ BRIGHTNESS_FACTOR * abs(((long) col->red +
COLOR_FACTOR * (labs((long) col->red - (long) cols[i].red)
+ labs((long) col->green - (long) cols[i].green)
+ labs((long) col->blue - (long) cols[i].blue))
+ BRIGHTNESS_FACTOR * labs(((long) col->red +
(long) col->green +
(long) col->blue)
- ((long) cols[i].red +
@@ -647,7 +647,8 @@ CreateColors(
while (def_index <= 5 && defaults[def_index] == NULL)
++def_index;
}
if (def_index >= 2 && defaults[def_index] != NULL &&
if (def_index >= 2 && def_index <= 5 &&
defaults[def_index] != NULL &&
!xpmstrcasecmp(symbol->value, defaults[def_index]))
break;
}

View File

@@ -234,8 +234,14 @@ xpmParseColors(
xpmFreeColorTable(colorTable, ncolors);
return (XpmNoMemory);
}
for (b = 0, s = color->string; b < cpp; b++, s++)
*s = xpmGetC(data);
for (b = 0, s = color->string; b < cpp; b++, s++) {
int c = xpmGetC(data);
if (c < 0) {
xpmFreeColorTable(colorTable, ncolors);
return (XpmFileInvalid);
}
*s = (char) c;
}
*s = '\0';
/*
@@ -322,8 +328,14 @@ xpmParseColors(
xpmFreeColorTable(colorTable, ncolors);
return (XpmNoMemory);
}
for (b = 0, s = color->string; b < cpp; b++, s++)
*s = xpmGetC(data);
for (b = 0, s = color->string; b < cpp; b++, s++) {
int c = xpmGetC(data);
if (c < 0) {
xpmFreeColorTable(colorTable, ncolors);
return (XpmFileInvalid);
}
*s = (char) c;
}
*s = '\0';
/*
@@ -505,8 +517,14 @@ do \
for (y = 0; y < height; y++) {
xpmNextString(data);
for (x = 0; x < width; x++, iptr++) {
for (a = 0, s = buf; a < cpp; a++, s++)
*s = xpmGetC(data); /* int assigned to char, not a problem here */
for (a = 0, s = buf; a < cpp; a++, s++) {
int c = xpmGetC(data);
if (c < 0) {
XpmFree(iptr2);
return (XpmFileInvalid);
}
*s = (char) c;
}
slot = xpmHashSlot(hashtable, buf);
if (!*slot) { /* no color matches */
XpmFree(iptr2);
@@ -519,8 +537,14 @@ do \
for (y = 0; y < height; y++) {
xpmNextString(data);
for (x = 0; x < width; x++, iptr++) {
for (a = 0, s = buf; a < cpp; a++, s++)
*s = xpmGetC(data); /* int assigned to char, not a problem here */
for (a = 0, s = buf; a < cpp; a++, s++) {
int c = xpmGetC(data);
if (c < 0) {
XpmFree(iptr2);
return (XpmFileInvalid);
}
*s = (char) c;
}
for (a = 0; a < ncolors; a++)
if (!strcmp(colorTable[a].string, buf))
break;