summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libXpm 3.5.15libXpm-3.5.15Alan Coopersmith2023-01-171-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Use gzip -d instead of gunzipPeter Hutterer2023-01-163-4/+3
| | | | | | | | | | | | | GNU gunzip [1] is a shell script that exec's `gzip -d`. Even if we call /usr/bin/gunzip with the correct built-in path, the actual gzip call will use whichever gzip it finds first, making our patch pointless. Fix this by explicitly calling gzip -d instead. https://git.savannah.gnu.org/cgit/gzip.git/tree/gunzip.in [Part of the fix for CVE-2022-4883] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Prevent a double free in the error code pathMatthieu Herrb2023-01-121-1/+5
| | | | | | | | | | | xpmParseDataAndCreate() calls XDestroyImage() in the error path. Reproducible with sxpm "zero-width.xpm", that file is in the test/ directory. The same approach is needed in the bytes_per_line == 0 condition though here it just plugs a memory leak. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix CVE-2022-4883: compression commands depend on $PATHAlan Coopersmith2023-01-124-5/+42
| | | | | | | | | | | | | | | | By default, on all platforms except MinGW, libXpm will detect if a filename ends in .Z or .gz, and will when reading such a file fork off an uncompress or gunzip command to read from via a pipe, and when writing such a file will fork off a compress or gzip command to write to via a pipe. In libXpm 3.5.14 or older these are run via execlp(), relying on $PATH to find the commands. If libXpm is called from a program running with raised privileges, such as via setuid, then a malicious user could set $PATH to include programs of their choosing to be run with those privileges. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix CVE-2022-44617: Runaway loop with width of 0 and enormous heightAlan Coopersmith2023-01-122-10/+41
| | | | | | | | | | | | | | When reading XPM images from a file with libXpm 3.5.14 or older, if a image has a width of 0 and a very large height, the ParsePixels() function will loop over the entire height calling getc() and ungetc() repeatedly, or in some circumstances, may loop seemingly forever, which may cause a denial of service to the calling program when given a small crafted XPM file to parse. Closes: #2 Reported-by: Martin Ettl <ettl.martin78@googlemail.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* test: add test cases for CVE-2022-44617 (zero-width w/enormous height)Alan Coopersmith2023-01-124-0/+77
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix CVE-2022-46285: Infinite loop on unclosed commentsAlan Coopersmith2023-01-121-0/+4
| | | | | | | | | | | | When reading XPM images from a file with libXpm 3.5.14 or older, if a comment in the file is not closed (i.e. a C-style comment starts with "/*" and is missing the closing "*/"), the ParseComment() function will loop forever calling getc() to try to read the rest of the comment, failing to notice that it has returned EOF, which may cause a denial of service to the calling program. Reported-by: Marco Ivaldi <raptor@0xdeadbeef.info> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* test: add test case for CVE-2022-46285 (unclosed comments)Alan Coopersmith2023-01-123-0/+34
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* cxpm: getc/ungetc wrappers should not adjust position when c == EOFAlan Coopersmith2023-01-101-2/+2
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* test: Add unit tests using glib frameworkAlan Coopersmith2023-01-0836-8/+3982
| | | | | | | | | | | | | Includes rudimentary tests for XpmReadFileToXpmImage, XpmReadFileToData, XpmReadFileToBuffer, XpmCreateXpmImageFromData, XpmCreateXpmImageFromBuffer, XpmWriteFileFromXpmImage, XpmWriteFileFromData, XpmWriteFileFromBuffer, XpmAttributesSize, XpmGetErrorString, XpmLibraryVersion Includes test cases for CVE-2004-0687 Tests .Z and .gz files if --enable-open-zfile is active Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* configure: add --disable-open-zfile instead of requiring -DNO_ZPIPEAlan Coopersmith2023-01-072-13/+38
| | | | | | | | Documents the two compression options in the README, makes their configure options reflect the interdependency of their implementation, and makes the configure script report their configuration. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Apply standard man page style/formattingAlan Coopersmith2023-01-018-269/+690
| | | | | | | | | | | | Function & macro names in bold, argument names in italics. In the man page body, bold function names followed by plain () for functions defined in this page, plain (3) for functions defined in other man pages. New paragraphs start with .PP, not just a blank line. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Replace "See Also" entries with more useful onesAlan Coopersmith2023-01-018-34/+34
| | | | | | | "See Also" entries in man pages should list other man pages to look at, not the alternate names for the current man page. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Fix typos and other minor editingAlan Coopersmith2023-01-015-17/+27
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* libXpm 3.5.14libXpm-3.5.14Alan Coopersmith2022-11-191-2/+2
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Correct Copyright/License noticesAlan Coopersmith2022-08-278-160/+152
| | | | | | | Since the text was copied from doc/xpm.PS.gz, the copyright and license notices need to be copied from there as well. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Fix typosAlan Coopersmith2022-08-276-15/+15
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Add missing word 'function' where neededAlan Coopersmith2022-08-274-8/+9
| | | | | | | A number of instances of 'The Xpm... function' were missing the word "function", so read awkwardly. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Make function synopses more consistent with other pagesAlan Coopersmith2022-08-278-34/+34
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Fix shadow man pagesAlan Coopersmith2022-08-2633-33/+33
| | | | | | | Shadow man pages have a .so line that needs to list the file to be shown, not the name of the shadow page. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man pages: Make file names consistent with their displayed namesAlan Coopersmith2022-08-269-11/+11
| | | | | | Lets users view the pages using the name displayed on the pages Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* gitlab CI: add a basic build testAlan Coopersmith2022-07-171-0/+98
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* man: strip trailing whitespaceAlan Coopersmith2022-07-179-347/+347
| | | | | | git diff -w shows no changes from this commit Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix spelling/wording issuesAlan Coopersmith2022-07-1713-18/+18
| | | | | | | Found by using: codespell --builtin clear,rare,usage,informal,code,names Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Build xz tarballs instead of bzip2Alan Coopersmith2022-07-171-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* update man pagesWalter Harms2019-12-258-274/+187
| | | | | | | move from k&r to ansi prototypes improve nroff coding Signed-off-by: Walter Harms <wharms@bfs.de>
* add man pages based on doc/xpm.PSWalter Harms2019-12-2443-4/+1023
| | | | | | | More or less hand crafted man pages based on xpm.PS. Prototypes are still in K&R, see also is a dud Signed-off-by: Walter Harms <wharms@bfs.de>
* libXpm 3.5.13libXpm-3.5.13Peter Hutterer2019-12-131-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* parse: simplify error paths in xpmParseColors()Benjamin Tissoires2019-12-061-26/+24
| | | | | | | We introduced a new label to handle the errors, we should use it for the rest of the function. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* parse: avoid memleak on error with STRLCAT/STRLCPYPeter Hutterer2019-12-061-20/+58
| | | | | | | | | The original macro might exit the function without freeing `colorTable`. Move the macros into a slightly less awful helper function and use goto to clean up in case of error. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Allow usage when fork() is not availableFabrice Fontaine2019-05-031-0/+1
| | | | | | | | | | | | When fork() is not available, we need to define NO_ZPIPE so that libXpm doesn't try to fork/exec to use a pipe to uncompress compressed .xpm files. There is obviously a loss of functionality, but loading uncompressed .xpm files should continue to work. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> [Retrieved from: https://git.buildroot.net/buildroot/tree/package/x11r7/xlib_libXpm/0001-fork-check.patch] Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
* Update configure.ac bug URL for gitlab migrationAlan Coopersmith2018-12-071-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Update README for gitlab migrationAlan Coopersmith2018-11-193-26/+19
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* After fdopen(), use fclose() instead of close() in error pathAlan Coopersmith2018-10-061-1/+1
| | | | | | | | | | | | | | | | | Found by Oracle's Parfait 2.2 static analyzer: Error: File Leak File Leak [file-ptr-leak]: Leaked File fp at line 94 of lib/libXpm/src/RdFToBuf.c in function 'XpmReadFileToBuffer '. fp initialized at line 86 with fdopen fp leaks when len < 0 at line 92. Introduced-by: commit 8b3024e6871ce50b34bf2dff924774bd654703bc Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* Windows build fixesDave Bodenstab2018-09-224-0/+19
| | | | | | | https://bugs.freedesktop.org/show_bug.cgi?id=46475 https://bugs.freedesktop.org/attachment.cgi?id=57479 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* autogen: add default patch prefixMihail Konev2017-01-261-0/+3
| | | | Signed-off-by: Mihail Konev <k.mvc@ya.ru>
* autogen.sh: use quoted string variablesEmil Velikov2017-01-261-4/+4
| | | | | | | | | Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent fall-outs, when they contain space. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* autogen.sh: use exec instead of waiting for configure to finishPeter Hutterer2017-01-261-1/+1
| | | | | | | Syncs the invocation of configure with the one from the server. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* libXpm 3.5.12libXpm-3.5.12Matthieu Herrb2016-12-121-1/+1
| | | | Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
* Handle size_t in file/buffer lengthTobias Stoeckmann2016-12-122-1/+5
| | | | | | | | The values of file sizes and buffer sizes can exceed current limits. Therefore, use proper variable types for these operations. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
* Avoid OOB write when handling malicious XPM files.Tobias Stoeckmann2016-12-121-9/+25
| | | | | | | | | | | | | | | | | libXpm uses unsigned int to store sizes, which fits size_t on 32 bit systems, but leads to issues on 64 bit systems. On 64 bit systems, it is possible to overflow 32 bit integers while parsing XPM extensions in a file. At first, it looks like a rather unimportant detail, because nobody will seriously open a 4 GB file. But unfortunately XPM has support for gzip compression out of the box. An attacker can therefore craft a compressed file which is merely 4 MB in size, which makes an attack much for feasable. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
* Gracefully handle EOF while parsing files.Tobias Stoeckmann2016-12-121-8/+32
| | | | | | | | | | | | | | | | | libXpm does not properly handle EOF conditions when xpmGetC is called multiple times in a row to construct a string. Instead of checking its return value for EOF, the result is automatically casted into a char and attached to a string. By carefully crafting the color table in an XPM file, it is possible to send a libXpm program like gimp into a very long lasting loop and massive memory allocations. Otherwise no memory issues arise, therefore this is just a purely functional patch to dismiss invalid input. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Matthieu Herrb <Matthieu@herrb.eu>
* Fix out out boundary read on unknown colorsTobias Stoeckmann2016-12-121-1/+2
| | | | | | | | | | | | libXpm is vulnerable to an out of boundary read if an XPM file contains a color with a symbolic name but without any default color value. A caller must set XpmColorSymbols and a color with a NULL name in the supplied XpmAttributes to XpmReadFileToImage (or other functions of this type) in order to trigger this issue. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
* Fix abs() usage.Jörg Sonnenberger2014-03-191-4/+4
| | | | | | | For long arguments, use labs(). Reviewed-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
* libXpm 3.5.11libXpm-3.5.11Alan Coopersmith2013-09-071-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix typo in COPYING (matches src/amigax.h)Alan Coopersmith2013-09-071-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Add noreturn attributes suggested by gccAlan Coopersmith2013-08-022-6/+4
| | | | | | | Remove extra bogus return added to avoid warnings when calling Punt() since gcc didn't know it would never return. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* doclifter can't handle more than one dash in a name line.Eric S. Raymond2013-06-191-1/+1
|
* Fix libXpm build with NO_ZPIPEClaudio Bley2013-05-311-1/+2
| | | | | | | | | | | When NO_ZPIPE is defined, fcntl.h is not included in WrFFrI.c although OpenWriteFile uses open, O_WRONLY, O_CREAT and O_TRUNC. * src/WrFFrI.c: unconditionally include fcntl.h regardless of NO_ZPIPE being defined or not. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Added 'const' attribute to all filename arguments in the APIChristophe CURIS2013-05-319-20/+20
| | | | | | | | | | | | | | The filename is always a read-only argument, so it is a good idea to let the caller now about it. This patch does not change active code; the place where the attribute is added will not break source-level compatibility because it adds no restriction on caller side, just adds information; because the lib code behaved the same way it will not break the binary interface either. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>