summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-05-24Clear some -Wuseless-cast warnings from gcc 14.1HEADmasterAlan Coopersmith1-1/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/25>
2025-05-24_IceWrite: accept const pointers for data to writeAlan Coopersmith2-2/+2
Will cause -Wdiscarded-qualifiers warnings unless built with xtrans commit e69d45306f3836 or later (included in xtrans 1.6.0). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/25>
2024-12-13libICE 1.1.2libICE-1.1.2Alan Coopersmith1-1/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-11-22ProcessAuthReply: Handle -Wconditional-uninitialized warningAlan Coopersmith1-1/+1
Clears warning from clang 13: process.c:1612:21: warning: variable 'authDataLen' may be uninitialized when used here [-Wconditional-uninitialized] if (authData && authDataLen > 0) ^~~~~~~~~~~ process.c:1344:22: note: initialize the variable 'authDataLen' to silence this warning int authDataLen; ^ = 0 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/23>
2024-11-22ICElibint.h: add do ... while (0) around macro definitionsAlan Coopersmith1-24/+24
Clears 71 warnings from clang 13 of the form: connect.c:351:39: warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt] STORE_STRING (pData, IceVendorString); ^ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/23>
2024-11-16libICE : Dereferencing a possible NULL pointer in error.cmahendra1-15/+25
In function _IceErrorSetupFailed at line no 188, IceAllocScratch is used to allocate memory for variable pStart and pBuf. IceAllocScratch is using malloc for memory allocation, malloc can return NULL on failure. So before dereferencing pStart and pBuf, NULL check must apply. v2 (by alanc): correct inverted tests for NULL from original patch Closes: #5 Signed-off-by: mahendra <mahendra.n@samsung.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/22>
2024-11-16write_counted_string: avoid undefined behavior in fwrite() callAlan Coopersmith1-1/+2
In C23 and earlier, it is undefined behavior to call fwrite() with a NULL pointer, even if the size to copy is zero bytes. Closes: #11 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/21>
2024-11-08AuthRequired: avoid undefined behavior in memcpy() callAlan Coopersmith1-4/+7
In C23 and earlier, it is undefined behavior to call memcpy() with a NULL pointer, even if the size to copy is zero bytes. Closes: #10 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/20>
2024-08-25IceRegisterForProtocolSetup: return failure if malloc() failedAlan Coopersmith1-0/+9
Clears warning from gcc 14.1: register.c: In function ‘IceRegisterForProtocolSetup’: register.c:92:15: warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference] 92 | p->vendor = strdup(vendor); | ~~~~~~~~~~^~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-25IceProtocolSetup: return failure if malloc() failed for authIndicesAlan Coopersmith1-0/+10
Clears warning from gcc 14.1: protosetup.c: In function ‘IceProtocolSetup’: protosetup.c:178:24: warning: dereference of NULL ‘authIndices’ [CWE-476] [-Wanalyzer-null-dereference] 178 | authIndices[i]]); | ~~~~~~~~~~~^~~ ICElibint.h:179:36: note: in definition of macro ‘STORE_STRING’ 179 | CARD16 _len = (CARD16) strlen (_string); \ | ^~~~~~~ ‘IceProtocolSetup’: events 1-8 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-25ProcessProtocolSetup: return failure if malloc() failed for ProtocolNameAlan Coopersmith1-0/+7
Clears warning from gcc 14.1: process.c: In function ‘ProcessProtocolSetup’: process.c:1956:56: warning: use of NULL ‘protocolName’ where non-null expected [CWE-476] [-Wanalyzer-null-argument] 1956 | if (iceConn->process_msg_info[i].in_use && strcmp (protocolName, | ^~~~~~~~~~~~~~~~~~~~ 1957 | iceConn->process_msg_info[i].protocol->protocol_name) == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-25ProcessConnectionSetup: avoid writing to NULL pointer if malloc() failedAlan Coopersmith1-1/+9
Clears warning from gcc 14.1: process.c: In function ‘ProcessConnectionSetup’: ICElibint.h:233:13: warning: dereference of possibly-NULL ‘hisAuthNames’ [CWE-690] [-Wanalyzer-possible-null-dereference] 233 | _string = malloc (_len + 1); \ ICElibint.h:247:9: note: in expansion of macro ‘EXTRACT_STRING’ 247 | EXTRACT_STRING (_pBuf, _swap, _strings[_i]); \ | ^~~~~~~~~~~~~~ process.c:947:9: note: in expansion of macro ‘EXTRACT_LISTOF_STRING’ 947 | EXTRACT_LISTOF_STRING (pData, swap, hisAuthCount, hisAuthNames); | ^~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-25IceReadCompleteMessage: callers need to check if malloc() failedAlan Coopersmith1-7/+7
The IceReadCompleteMessage() macro may try to malloc() a buffer and assign it to the final argument. Clears up 12 -Wanalyzer-null-dereference warnings from gcc 14.1 of the form: process.c: In function ‘ProcessError’: ICElibint.h:214:10: warning: dereference of NULL ‘pStart’ [CWE-476] [-Wanalyzer-null-dereference] 214 | _val = *((CARD16 *) _pBuf); \ | ^ ICElibint.h:232:5: note: in expansion of macro ‘EXTRACT_CARD16’ 232 | EXTRACT_CARD16 (_pBuf, _swap, _len); \ | ^~~~~~~~~~~~~~ process.c:689:17: note: in expansion of macro ‘EXTRACT_STRING’ 689 | EXTRACT_STRING (pData, swap, temp); | ^~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-25Clear some -Wuseless-cast warnings from gcc 14.1Alan Coopersmith2-3/+3
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-24_IceAddOpcodeMapping: Avoid writing to NULL pointer if malloc failsAlan Coopersmith1-0/+10
Clears warning from gcc 14.1: misc.c: In function ‘_IceAddOpcodeMapping’: misc.c:435:9: warning: use of possibly-NULL ‘*iceConn.process_msg_info’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] 435 | memcpy (iceConn->process_msg_info, oldVec, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 436 | oldsize * sizeof (_IceProcessMsgInfo)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-24EXTRACT_STRING: Avoid writing to NULL pointer if malloc failsAlan Coopersmith1-2/+4
Fixes several warnings from gcc 14.1 of the form: In file included from error.c:33: error.c: In function ‘_IceDefaultErrorHandler’: ICElibint.h:234:5: warning: use of possibly-NULL ‘estr’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] 234 | memcpy (_string, _pBuf, _len); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error.c:515:13: note: in expansion of macro ‘EXTRACT_STRING’ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-24ConnectToPeer: return failure if malloc() failsAlan Coopersmith1-0/+2
Fixes warning from gcc 14.1: connect.c: In function ‘ConnectToPeer’: connect.c:541:9: warning: use of possibly-NULL ‘address’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] 541 | strncpy (address, ptr, len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2024-08-24IceOpenConnection: stop processing messages if connection was closedAlan Coopersmith1-1/+1
Fixes warning from gcc 14.1 in cases where the connection was closed and iceConn set to NULL on a previous time through the loop. connect.c: In function ‘IceOpenConnection’: connect.c:439:51: warning: dereference of NULL ‘iceConn’ [CWE-476] [-Wanalyzer-null-dereference] 439 | iceConn->my_ice_version_index = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 440 | reply.connection_reply.version_index; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libice/-/merge_requests/19>
2023-10-13gitlab CI: add xz-utils to container for "make distcheck"Alan Coopersmith1-2/+2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-10-13gitlab CI: Update to latest CI templatesAlan Coopersmith1-2/+2
Current template fails to rebuild the CI container with the current Debian stable release (a new release since the last update) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-03-28Set close-on-exec when opening filesAlan Coopersmith3-3/+10
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-03-04configure: Use LT_INIT from libtool 2 instead of deprecated AC_PROG_LIBTOOLAlan Coopersmith1-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>
2022-12-08libICE 1.1.1libICE-1.1.1Matt Turner1-1/+1
Signed-off-by: Matt Turner <mattst88@gmail.com>
2022-12-04ICEmsg: Fix C++ interoperability error due to static_assert defineArsen Arsenović1-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
2022-12-03libICE 1.1.0libICE-1.1.0Alan Coopersmith1-2/+2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-11-23configure: Use AC_SYS_LARGEFILE to enable large file supportAlan Coopersmith1-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>
2022-11-10ice.pc.in: "Libs.Private" should be "Libs.private"Alan Coopersmith1-1/+1
Fixes: b9411f7 ("ice.pc.in: add -lbsd flags when required") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-11-02Avoid -Wdeclaration-after-statement warnings from static_assertAlan Coopersmith1-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>
2022-10-27Only link with libbsd if needed for arc4random_buf() or getentropy()Alan Coopersmith1-2/+9
Avoid unnecessary library dependency when using a libc with these functions included Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-10-06Switch from libbsd to libbsd-overlayGuillem Jover3-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>
2022-09-14Handle arrays too large to fit in iceConn buffersAlan Coopersmith4-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>
2022-09-07ICEmsg.h: Add static asserts that message header length <= ICE_OUTBUFSIZEAlan Coopersmith1-0/+9
A message header length larger than ICE_OUTBUFSIZE will cause buffer overflows. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-09-07IceFlush: signal fatal I/O error if bufptr is past end of bufferAlan Coopersmith1-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>
2022-09-07Refactor Fatal I/O error handling into a common functionAlan Coopersmith2-85/+48
Reduce duplicated code in _IceRead() and _IceWrite() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-09-07IceGetHeaderExtra: only include extra space in outbufptr if there's roomAlan Coopersmith1-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>
2022-08-20Only link to libbsd for arc4random_buf if it is not found in libcAlan Coopersmith1-2/+3
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-08-20make sure buffer is zero filled and report if allocation failedwalter harms1-1/+4
Signed-off-by: Walter Harms <wharms@bfs.de> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-08-20add check for mallocwalter harms1-0/+2
fix a potential null pointer deference error Signed-off-by: Walter Harms <wharms@bfs.de>
2022-04-30connect.c: FIX 'iceConn' shadows a previous local, [-Wshadow]walter harms1-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>
2022-04-30ProcessAuthReply: rename status variable to avoid shadowingAlan Coopersmith1-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>
2022-04-30ConnectToPeer: be doubly sure that use-after-free doesn't happenAlan Coopersmith1-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>
2022-04-30configure: check for libbsd before libxtrans checks for strlcpyAlan Coopersmith1-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>
2022-04-30gitlab CI: add a basic build testAlan Coopersmith1-0/+99
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-04-30Fix spelling/wording issuesAlan Coopersmith12-18/+18
Found by using: codespell --builtin clear,rare,usage,informal,code,names Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-04-30Build xz tarballs instead of bzip2Alan Coopersmith1-1/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-04-11ice.pc.in: add -lbsd flags when requiredDavid Callu2-0/+9
2019-07-14libICE 1.0.10libICE-1.0.10Alan Coopersmith1-1/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-04-11cleanup: Separate variable assignment and testOlivier Fourdan1-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>
2019-04-10_IceRead: Avoid possible use-after-freeOlivier Fourdan1-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>
2019-04-10IceListenForWellKnownConnections: Fix memleakOlivier Fourdan1-0/+1
The function `_IceTransMakeAllCOTSServerListeners` allocates memory for `transConns` which is leaked in case of error. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>