From 836a8f2cf5e930c8a56b512273fdf9890282ba04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Tue, 30 Apr 2024 16:49:26 +0200 Subject: [PATCH 3/6] Fix use of uninitialized variable in _XimEncodeICATTRIBUTE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the `res->resource_size == XimType_NEST` code path, if `res->xrm_name != pre_quark` and `res->xrm_name != sts_quark`, `len` can be used uninitialized. This error has been found by a static analysis tool. This is the report: Error: UNINIT (CWE-457): libX11-1.8.7/modules/im/ximcp/imRmAttr.c:1106: var_decl: Declaring variable "len" without initializer. libX11-1.8.7/modules/im/ximcp/imRmAttr.c:1179: uninit_use: Using uninitialized value "len". # 1177| } # 1178| # 1179|-> if (len == 0) { # 1180| continue; # 1181| } else if (len < 0) { Signed-off-by: José Expósito Part-of: --- modules/im/ximcp/imRmAttr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/im/ximcp/imRmAttr.c b/modules/im/ximcp/imRmAttr.c index 709e64ab..c56bd62e 100644 --- a/modules/im/ximcp/imRmAttr.c +++ b/modules/im/ximcp/imRmAttr.c @@ -1115,6 +1115,7 @@ _XimEncodeICATTRIBUTE( *ret_len = 0; for (p = arg; p && p->name; p++) { + len = 0; buf_s = (CARD16 *)buf; if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) { if (_XimSetInnerICAttributes(ic, top, p, mode)) -- 2.45.2