summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* If O_CLOEXEC is defined, add "e" to fopen modesHEADmasterAlan Coopersmith2023-03-254-10/+17
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* more cppcheck-style fixesThomas E. Dickey2021-05-062-14/+12
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* cppcheck style-fixesThomas E. Dickey2021-05-054-11/+7
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* fix XcursorTheme loop regressionTobias Stoeckmann2021-05-041-13/+8
| | | | | | | | | | | | | | | | | | | | Handle themes with multiple inherit entries. Although the previous commit keeped track of inherited themes, it only handled multiple theme entries on the highest level. This fix unconditionally checks if the next upper level contains a line. If it does, it processes contained themes (i.e. the current theme had an inherited entry in its index file). If the upper level has no more themes, it goes down a level and processes the next theme there. If no next theme exists, it moves down another level and so on until it reaches level 0, i.e. the initially supplied theme. The lowest level (d = 0) is treated specially because we must not modify the supplied theme, which could happen when calling _XcursorNextPath. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* Handle more theme loop situationsTobias Stoeckmann2021-05-021-36/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow up for commit f64a8cc1a65dcad4294e2988b402a34175019663 resulting from https://bugs.freedesktop.org/show_bug.cgi?id=3603 The current loop detection only works for direct self references but not for transitive ones. Limiting the inheritance depth fixes this issue as suggested by Keith Packard. I avoided the introduction of a recursion function. Instead I modified XcursorScanTheme to work iterative. The current recursion code adds the "Inherits=..." line to heap and has an iteration variable to go through all themes listed in that line per recursion. This is covered with the newly introduced XcursorInherit struct with its fields "line" and "theme". Since "theme" points into "line", only "line" has to be freed eventually. If a fixed inheritage limit of 32 is reached, the code stops processing and returns NULL. It also returns NULL if it detects the initial theme in one of the inheritages to break the loop early on. Last but not least I removed the printf statement. The only situation in which libXcursor writes to stdout is when it is explicitly requested. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* amend that...Thomas E. Dickey2021-03-111-1/+1
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* add check in case the image size is 0x0Thomas E. Dickey2021-03-111-1/+1
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* fix stricter gcc warnings using castsThomas E. Dickey2021-03-111-11/+11
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* fix stricter gcc warnings using castsThomas E. Dickey2021-03-111-1/+1
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* fix stricter gcc warnings by changing the type for the loop variable toThomas E. Dickey2021-03-111-11/+11
| | | | | | match the type of the loop limit Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* quiet warnings for unused parametersThomas E. Dickey2021-03-112-0/+6
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* fix a missing initializerThomas E. Dickey2021-03-111-2/+4
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* quiet normal gcc warnings using casts (no object change)Thomas E. Dickey2021-03-115-59/+64
| | | | Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
* Fix undefined behaviorValentin2020-08-301-5/+6
| | | | | | Without the casts the bytes accesses get converted to int. but int is not guaranteed to be 4 bytes large. Even when it is 4 bytes large `bytes[3] << 24` does not fit because int is signed.
* Support XDG user data dir locationCosimo Cecchi2018-11-091-1/+1
| | | | | | | | | | Nowadays ~/.icons is not used anymore as the preferred location for custom user icon themes; XDG_DATA_HOME/icons (aka ~/.local/share/icons) is what toolkits like GTK prefer. Prepend that location to the default xcursor path, so that cursor themes installed there can be used by apps and toolkits that use libXcursor.
* Fix crash when encountering cursor themes with circular dependencies.Philipp Ludwig2018-03-231-1/+6
| | | | | | | https://bugs.freedesktop.org/show_bug.cgi?id=3603 Signed-off-by: Philipp Ludwig <git-devel@philippludwig.net> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix heap overflows when parsing malicious files. (CVE-2017-16612)Tobias Stoeckmann2017-11-251-2/+10
| | | | | | | | | | | | | | | | | | | | It is possible to trigger heap overflows due to an integer overflow while parsing images and a signedness issue while parsing comments. The integer overflow occurs because the chosen limit 0x10000 for dimensions is too large for 32 bit systems, because each pixel takes 4 bytes. Properly chosen values allow an overflow which in turn will lead to less allocated memory than needed for subsequent reads. The signedness bug is triggered by reading the length of a comment as unsigned int, but casting it to int when calling the function XcursorCommentCreate. Turning length into a negative value allows the check against XCURSOR_COMMENT_MAX_LEN to pass, and the following addition of sizeof (XcursorComment) + 1 makes it possible to allocate less memory than needed for subsequent reads. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
* Insufficient memory for terminating null of string in _XcursorThemeInheritsshubham shrivastav2015-06-051-1/+1
| | | | | | | | Fix does one byte of memory allocation for null termination of string. https://bugs.freedesktop.org/show_bug.cgi?id=90857 Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix some clang integer sign/size mismatch warningsAlan Coopersmith2014-10-182-3/+3
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Use strdup() instead of malloc(strlen())+strcpy()Alan Coopersmith2014-10-182-15/+4
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* signedness bug & integer overflow in _XcursorFileHeaderCreate() [CVE-2013-2003]Alan Coopersmith2013-04-261-1/+1
| | | | | | | | | | | | | | | | When parsing cursor files, a user defined (e.g. through environment variables) cursor file is opened and parsed. The header is read in _XcursorReadFileHeader(), which reads an unsigned int for the number of toc structures in the header, but it was being passed to _XcursorFileHeaderCreate() as a signed int to allocate those structures. If the number was negative, it would pass the bounds check and could overflow the calculation for how much memory to allocate to store the data being read, leading to overflowing the buffer with the data read from the user controlled file. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Replace deprecated Automake INCLUDES variable with AM_CPPFLAGSbaserock/morphAlan Coopersmith2013-01-151-1/+1
| | | | | | | | | | | | | Excerpt https://lists.gnu.org/archive/html/automake/2012-12/msg00038.html - Support for the long-deprecated INCLUDES variable will be removed altogether in Automake 1.14. The AM_CPPFLAGS variable should be used instead. This variable was deprecated in Automake releases prior to 1.10, which is the current minimum level required to build X. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* XcursorImageLoadCursor: return failure if _XcursorGetDisplayInfo failsAlan Coopersmith2011-11-301-0/+3
| | | | | | | | | | | | | | Error: Null pointer dereference (CWE 476) Read from null pointer 'info' at line 615 of src/cursor.c in function 'XcursorImageLoadCursor'. Function '_XcursorGetDisplayInfo' may return constant 'NULL' at line 134, called at line 597. Null pointer introduced at line 134 of src/display.c in function '_XcursorGetDisplayInfo'. [ This bug was found by the Parfait 0.3.7 bug checking tool. For more information see http://labs.oracle.com/projects/parfait/ ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
* XcursorFileSaveImages: plug memory leak on invalid inputAlan Coopersmith2011-11-301-2/+5
| | | | | | | | | | | | | | Error: Memory leak (CWE 401) Memory leak of pointer 'comments' allocated with XcursorCommentsCreate(0) at line 982 of src/file.c in function 'XcursorFileSaveImages'. 'comments' allocated at line 978 with XcursorCommentsCreate(0). comments leaks when comments != 0 at line 981. [ This bug was found by the Parfait 0.3.7 bug checking tool. For more information see http://labs.oracle.com/projects/parfait/ ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
* Fix install of generated Xcursor.h when builddir != srcdirJon TURNEY2011-09-251-1/+1
| | | | | | | Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Gaetan Nadon <memsize@videotron.ca> Tested-by: Gaetan Nadon <memsize@videotron.ca> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Strip trailing whitespaceAlan Coopersmith2011-09-167-110/+110
| | | | | | | Performed with: find * -type f | xargs perl -i -p -e 's{\s+$}{\n}' git diff -w & git diff -b show no diffs from this change Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Mark bitmasks as unsigned intsAlan Coopersmith2011-05-221-2/+2
| | | | | | | | Clears Sun compiler warnings from shifting 8 bits by 24 bits: "cursor.c", line 215: warning: integer overflow detected: op "<<" "cursor.c", line 280: warning: integer overflow detected: op "<<" Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Correct error handling in _XcursorAverageColorJeremy Huddleston2011-05-071-2/+3
| | | | | | | | | | | Previously it would either div-zero or get stuck in a loop until int overflow if called with a bad value. cursor.c:214:32: warning: Division by zero return (0xff << 24) | ((red/npixels) << 16) | ((green/npixels) << 8) | (blue/npixels); Found-by: clang static analyzer Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
* Free the FontInfo structure after loading the cursor from it.Chris Wilson2011-04-011-0/+1
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=2731 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Free the partial header after failing to open the cursor.Chris Wilson2011-04-011-0/+3
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Free list on shutdown.Chris Wilson2011-04-011-0/+7
| | | | | | | We freed the parent structure without freeing the list contained within, making valgrind unhappy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* config: move CWARNFLAGS from configure.ac to Makefile.amGaetan Nadon2010-02-161-2/+5
| | | | | | | Compiler warning flags should be explicitly set in the makefile rather than being merged with other packages compiler flags. Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
* Janitor: make distcheck, compiler warnings, extra .gitignore files.Paulo Cesar Pereira de Andrade2009-01-292-8/+2
|
* nuke RCS IdsMatthieu Herrb2008-03-096-12/+0
|
* Store the cursor names in one large string.Tilman Sauerbeck2007-05-121-39/+96
| | | | | | This means the compiler doesn't need to place the array in the read-write sections of the DSO, which means less relocations when the library is loaded and a smaller memory footprint.
* Fix many sparse warnings: Using plain integer as NULL pointerAlan Coopersmith2006-10-105-85/+85
|
* Fix lint warning: deallocating a pointer that could be NULL: library.c(266)Alan Coopersmith2006-10-101-1/+2
|
* Add XORG_WITH_LINT to allow checking code with lint/sparse/etc.Alan Coopersmith2006-10-101-0/+8
|
* fix leak in header destructionChris Wilson2006-08-123-8/+10
| | | | Fix a couple of if (!foo) free(foo); tests.
* renamed: .cvsignore -> .gitignoreAlan Coopersmith2006-07-131-0/+0
|
* Bug #5268: Fix small memory leak. (Matthias Clasen). Change some return 0sxcursor-1_1_7Daniel Stone2006-06-031-4/+10
| | | | to NULL. Bump to 1.1.7.
* Coverity #159: Prevent a possible NULL chase.XORG-7_0_99_901Adam Jackson2006-04-071-1/+2
|
* Add configure options to allow hard-coded paths to be changed.Kevin E Martin2005-12-081-1/+5
|
* Allow hard-coded paths to be configurable.Kevin E Martin2005-12-081-2/+4
|
* Bug #4244: Make XcursorSetTheme(dpy, NULL) restore the default theme.Adam Jackson2005-10-192-8/+30
| | | | (Frederico Mena-Quintero)
* Do PKG_CHECK_MODULES on a unique token instead of on "DEP", so builds withAdam Jackson2005-08-031-2/+2
| | | | a global configure cache don't get confused.
* Change soversion to 1.0.2 with -version-number.Daniel Stone2005-07-161-1/+1
|
* Add .cvsignore files Switch _la_CFLAGS for AM_CFLAGS to clean up directoryKeith Packard2005-07-092-2/+8
|
* Make sure XFIXES appears in LIBS line, fix up other pkg-config usage.Keith Packard2005-07-081-1/+1
|
* Add appropriate lib*_CFLAGS to Makefile.am's -- fixes build problemsKevin E Martin2005-07-021-0/+1
|