summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Set close-on-exec when opening filesHEADmasterAlan Coopersmith2023-03-283-3/+10
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* configure: Use LT_INIT from libtool 2 instead of deprecated AC_PROG_LIBTOOLAlan Coopersmith2023-03-041-2/+3
| | | | | | | | | | | | | | | | | AC_PROG_LIBTOOL was replaced by LT_INIT in libtool 2 in 2008, so it's time to rely on it. Clears autoconf warnings: configure.ac:18: warning: The macro `AC_PROG_LIBTOOL' is obsolete. configure.ac:18: You should run autoupdate. aclocal.m4:3640: AC_PROG_LIBTOOL is expanded from... configure.ac:18: the top level libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac, libtoolize: and rerunning libtoolize and aclocal. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* libICE 1.1.1libICE-1.1.1Matt Turner2022-12-081-1/+1
| | | | Signed-off-by: Matt Turner <mattst88@gmail.com>
* ICEmsg: Fix C++ interoperability error due to static_assert defineArsen Arsenović2022-12-041-1/+1
| | | | | | | | | Commit 0269c687e954db7aca2a4344e32cb203315a00b6 added a static_assert helper that gets defined to blank if left undefined by assert.h. As this is not a macro in other languages that use this header, this can lead to a compile-time error. Bug: https://bugs.gentoo.org/884369
* libICE 1.1.0libICE-1.1.0Alan Coopersmith2022-12-031-2/+2
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* configure: Use AC_SYS_LARGEFILE to enable large file supportAlan Coopersmith2022-11-231-0/+3
| | | | | | | | | | | The only files libICE operates on are .ICEauthority files, which it only uses internally and does not make available to other code, so there is no concern about ABI mismatch here. While .ICEauthority files should never be more than 2gb in size, they may be stored on filesystems with large inodes. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* ice.pc.in: "Libs.Private" should be "Libs.private"Alan Coopersmith2022-11-101-1/+1
| | | | | Fixes: b9411f7 ("ice.pc.in: add -lbsd flags when required") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Avoid -Wdeclaration-after-statement warnings from static_assertAlan Coopersmith2022-11-021-2/+6
| | | | | | | | | | | | | | | | | | | | | Some implementations of static_assert() define a new variable. Avoid warnings from those when calling static_assert() from a macro that may not be at the top of a new code block. ../../src/accept.c: In function 'IceAcceptConnection': ../../src/accept.c:159:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 159 | IceGetHeader (iceConn, 0, ICE_ByteOrder, | ^~~~~~~~~~~~ ../../src/connect.c: In function 'IceOpenConnection': ../../src/connect.c:254:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 254 | IceGetHeader (iceConn, 0, ICE_ByteOrder, | ^~~~~~~~~~~~ ../../src/connect.c:340:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 340 | IceGetHeaderExtra (iceConn, 0, ICE_ConnectionSetup, | ^~~~~~~~~~~~~~~~~ [...etc...] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Only link with libbsd if needed for arc4random_buf() or getentropy()Alan Coopersmith2022-10-271-2/+9
| | | | | | | Avoid unnecessary library dependency when using a libc with these functions included Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Switch from libbsd to libbsd-overlayGuillem Jover2022-10-063-10/+7
| | | | | | | | This is the preferred usage form for libbsd, as it makes the code more portable and requires no special includes for libbsd, by transparently injects the needed standard headers that would be used on a BSD. Signed-off-by: Guillem Jover <guillem@hadrons.org>
* Handle arrays too large to fit in iceConn buffersAlan Coopersmith2022-09-144-17/+74
| | | | | | | | | | | | | | | | | Fixes numerous gcc warnings of the form: connect.c: In function ‘IceOpenConnection’: ICElibint.h:160:25: warning: potential null pointer dereference [-Wnull-dereference] *((CARD16 *) _pBuf) = _val; \ ^ ICElibint.h:174:5: note: in expansion of macro ‘STORE_CARD16’ STORE_CARD16 (_pBuf, _len); \ ^~~~~~~~~~~~ connect.c:351:5: note: in expansion of macro ‘STORE_STRING’ STORE_STRING (pData, IceReleaseString); ^~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* ICEmsg.h: Add static asserts that message header length <= ICE_OUTBUFSIZEAlan Coopersmith2022-09-071-0/+9
| | | | | | | A message header length larger than ICE_OUTBUFSIZE will cause buffer overflows. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* IceFlush: signal fatal I/O error if bufptr is past end of bufferAlan Coopersmith2022-09-071-0/+10
| | | | | | | | | It should never happen, but has been possible in the past when we didn't handle buffer checks properly - this would help us catch it if a similar mistake ever happens again (or the wrong memory pointer gets corrupted by something else). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Refactor Fatal I/O error handling into a common functionAlan Coopersmith2022-09-072-85/+48
| | | | | | Reduce duplicated code in _IceRead() and _IceWrite() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* IceGetHeaderExtra: only include extra space in outbufptr if there's roomAlan Coopersmith2022-09-071-4/+5
| | | | | | | | If there's not room for it in the buffer, we already set pData to NULL, but still set the outbufptr to include the space, which could lead to IceFlush() reading past the end of the buffer. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Only link to libbsd for arc4random_buf if it is not found in libcAlan Coopersmith2022-08-201-2/+3
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* make sure buffer is zero filled and report if allocation failedwalter harms2022-08-201-1/+4
| | | | | Signed-off-by: Walter Harms <wharms@bfs.de> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* add check for mallocwalter harms2022-08-201-0/+2
| | | | | | fix a potential null pointer deference error Signed-off-by: Walter Harms <wharms@bfs.de>
* connect.c: FIX 'iceConn' shadows a previous local, [-Wshadow]walter harms2022-04-301-17/+17
| | | | | | | | | In function 'IceOpenConnection': gcc give the following warning: connect.c:106:11: warning: declaration of 'iceConn' shadows a previous local [-Wshadow] fixed by renaming 2. iceConn to iConn (and all its uses) Signed-off-by: Walter Harms <wharms@bfs.de> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* ProcessAuthReply: rename status variable to avoid shadowingAlan Coopersmith2022-04-301-3/+3
| | | | | | | | | | | | | | Fixes gcc complaint: process.c: In function ‘ProcessAuthReply’: process.c:1478:20: warning: declaration of ‘status’ shadows a previous local [-Wshadow] 1478 | Status status = 1; | ^~~~~~ process.c:1426:25: note: shadowed declaration is here 1426 | IcePaAuthStatus status = | ^~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* ConnectToPeer: be doubly sure that use-after-free doesn't happenAlan Coopersmith2022-04-301-0/+1
| | | | | | | | | | | | | | | | | | This resolves an issue reported by the Oracle Parfait static analyzer: Error: Use after free Use after free [use-after-free] (CWE 416): Use after free of pointer trans_conn at line 566 of lib/libICE/src/connect.c in function 'ConnectToPeer'. trans_conn previously freed with _IceTransClose at line 532 trans_conn was allocated at line 525 with _IceTransOpenCOTSClient even though I believe this is already handled by the 'if (madeConnection) { ... } else trans_conn = NULL;' block, but the analyzer apparently doesn't follow that logic, while this simple change makes it obvious. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* configure: check for libbsd before libxtrans checks for strlcpyAlan Coopersmith2022-04-301-12/+9
| | | | | | If we're going to link to libbsd, might as well use it for strlcpy too Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* gitlab CI: add a basic build testAlan Coopersmith2022-04-301-0/+99
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix spelling/wording issuesAlan Coopersmith2022-04-3012-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-04-301-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* ice.pc.in: add -lbsd flags when requiredDavid Callu2020-04-112-0/+9
|
* libICE 1.0.10libICE-1.0.10Alan Coopersmith2019-07-141-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* cleanup: Separate variable assignment and testOlivier Fourdan2019-04-111-2/+4
| | | | | | | | | Assigning and testing a value in a single statement hinders code clarity and may confuses static code analyzers. Separate the assignment and the test for clarity. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
* _IceRead: Avoid possible use-after-freeOlivier Fourdan2019-04-101-1/+0
| | | | | | | | | | | | | `_IceRead()` gets called from multiple places which do not expect the connection to be freed. Do not free the connection data in `_IceRead()` to avoid potential use-after-free issue in the various callers. The connection data will be freed eventually in `ProcessWantToClose()`, so not freeing it in `_IceRead()` should not introduce an memory leak. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
* IceListenForWellKnownConnections: Fix memleakOlivier Fourdan2019-04-101-0/+1
| | | | | | | The function `_IceTransMakeAllCOTSServerListeners` allocates memory for `transConns` which is leaked in case of error. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
* IceWritePad: always use zero values for pad bytesAlan Coopersmith2019-03-241-10/+2
| | | | | | | Previously it would just bump the pointer in the buffer leaving whatever values were previously there in place. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* IceOpenConnection: check for malloc failure on connect_to_you tooAlan Coopersmith2019-03-241-0/+9
| | | | | | | Fixes: https://gitlab.freedesktop.org/xorg/lib/libice/issues/4 Reported-by: mahendra <mahendra.n@samsung.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* authutil: support $XDG_RUNTIME_DIR/ICEauthorityAllison Lortie2019-03-241-5/+13
| | | | | | | | | If we find that $XDG_RUNTIME_DIR is set (and $ICEAUTHORITY is not), then the ICEauthority file is stored in the XDG_RUNTIME_DIR instead of the home directory, and without a leading dot. https://bugs.freedesktop.org/show_bug.cgi?id=49173 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* authutil: fix an out-of-bounds accessAllison Lortie2019-03-241-2/+2
| | | | | | | | | | | | There is a theoretical edge case where the $HOME environment variable could be set to the empty string. IceAuthFileName() unconditionally checks index 1 of this string, which is out of bounds. Fix that up by rejecting empty strings in the same way as we reject NULL. https://bugs.freedesktop.org/show_bug.cgi?id=49173 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Always terminate strncpy results.Tobias Stoeckmann2019-03-104-41/+110
| | | | | | | | | | The function strncpy does not guarantee to append a terminating NUL character to the destination. This patch merges libSM's way of handling this issue into libICE. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* iceauth.c: FIX warning: unused variable 'ret' in 'arc4random_buf'walter harms2019-03-031-1/+1
| | | | | | | | | | | | | | commit ff5e59f32255913bb1cdf51441b98c9107ae165b left ret outside the #if causing a gcc warning: In function 'arc4random_buf': iceauth.c:89:13: warning: unused variable 'ret' [-Wunused-variable] fixed by moving #if 1 up Signed-off-by: Walter Harms <wharms@bfs.de> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.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-183-30/+25
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Remove obsolete B16 & B32 tags in struct definitionsAlan Coopersmith2018-11-102-17/+17
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* make IceProtocolShutdown() more readablewalter harms2017-09-141-22/+14
| | | | | | | | | | | I found IceProtocolShutdown() hard to read only to find that was it does it aktually very simple. So i rearranged the code to make it more readable. Signed-off-by: Walter Harms <wharms@bfs.de> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> [Emil Velikov: whitespace fixes] Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
* Drop NULL check prior to free()walter harms2017-09-144-73/+39
| | | | | | | | free() can handle NULL just fine - remove the check. Signed-off-by: Walter Harms <wharms@bfs.de> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* Make sure string is never NULLEric Engestrom2017-09-071-2/+12
| | | | | | | | | | `error_message` is passed in to strncpy() without any check, which doesn't handle NULL itself, so let's make it a valid empty string in cases where it was NULL. Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Walter Harms <wharms@bfs.de> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* Make sure error_message is a free-able stringEric Engestrom2017-09-071-2/+2
| | | | | | | | | Similar to the previous commit, assigning a static string would crash upon freeing. Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Walter Harms <wharms@bfs.de> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* Make sure errorStr is a free-able stringEric Engestrom2017-09-071-1/+1
| | | | | | | | | | | | If the `errorClass` isn't handled by the switch, `errorStr`'s initial value would be a pointer to some static memory with an empty string, and freeing it would most likely crash. Let's set it to NULL instead, as is done in other similar places. Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Walter Harms <wharms@bfs.de> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* configure.ac: set TRANS_CLIENT/SERVEREmil Velikov2017-09-073-5/+3
| | | | | | | | | Similar to ICE_t just set the define globally and remove the multiple definitions throughout the tree Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
* Kill off local ICE_t definitionsEmil Velikov2017-09-072-2/+1
| | | | | | | | Already defined at global scale in configure.ac Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
* Remove unneeded ^L symbols.Emil Velikov2017-09-0715-71/+71
| | | | | | Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
* Kill off Time_t macroEmil Velikov2017-09-072-4/+2
| | | | | | | | | Analogous to previous commit, including the megacommit that removed the need for it. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
* Kill off Strstr macroEmil Velikov2017-09-071-3/+1
| | | | | | | | | | | | | | | Directly use the strstr function as opposed to wrapping it in a macro. The latter is no longer needed as of commit 72e353567f8927996a26e72848d86f692c3f0737 Author: Kaleb Keithley <kaleb@freedesktop.org> Date: Fri Nov 14 16:48:46 2003 +0000 XFree86 4.3.0.1 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (IRC)
* Use getentropy() if arc4random_buf() is not availableBenjamin Tissoires2017-04-242-20/+47
| | | | | | | | | | | | | | | This allows to fix CVE-2017-2626 on Linux platforms without pulling in libbsd. The libc getentropy() is available since glibc 2.25 but also on OpenBSD. For Linux, we need at least a v3.17 kernel. If the recommended arc4random_buf() function is not available, emulate it by first trying to use getentropy() on a supported glibc and kernel. If the call fails, fall back to the current (partly vulnerable) code. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>