From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx08-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by sourceware.org (Postfix) with ESMTPS id 2A7963858426 for ; Thu, 24 Aug 2023 11:33:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A7963858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 37O9cUe2000385 for ; Thu, 24 Aug 2023 13:33:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=selector1; bh=xG95D+qbTRvfCpmgA+Zh pNLU1izv6DyqulJR28/OwlI=; b=CmUoDbmILeo96Qqn3fg/1h66PI71z1ie/hkT gxCQxs2OJL4bMgkfWUreE/0SnEjW6j+aFd9QftSDikHD5ELVKRjatx5+qBqc8PoV SZzYMqwKZJNDNTZEFz4TFb7Btl6eUpFMxIXxgBZrviXUH7RFhtvSUThCuu8inq/c OoXxUV/LXt3zjspWH4D+aTjrsXiXX245LRt7g7OSrkrYh6JX/7adXTD3rs5+bYhm NYuT/7P9/rBHwCeUKTucg07muEVxMkg7TFkZc8YAiLTfkUimFirgSAmBPVR7aW4V 7hISjCCIqiSobhRJ1q22nXA4ts9BASVXcEfCZ0qElunaNvNOxQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3sn1y5qmbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 24 Aug 2023 13:33:16 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 22EFB10005C for ; Thu, 24 Aug 2023 13:33:15 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E598822D16E for ; Thu, 24 Aug 2023 13:33:15 +0200 (CEST) Received: from jkgcxl0004.jkg.st.com (10.74.22.255) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 24 Aug 2023 13:33:15 +0200 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= To: CC: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= , Yvan ROUX Subject: [PATCH] libctf: ctf_member_next needs to return (ssize_t)-1 on error Date: Thu, 24 Aug 2023 13:32:49 +0200 Message-ID: <20230824113249.1197514-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.74.22.255] X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-24_08,2023-08-24_01,2023-05-22_02 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The function ctf_member_next should return (ssize_t)-1 on error. As the function ctf_set_errno returns (ctf_id_t)-1L and that is then casted to "unsigned long" as it's the return type of the function, it's not compatible and causes the value 0xffffffff to be returned on 64-bit Windows builds. As a result, the check for a negative value in ctf_dedup_rhash_type will never be true and a resulting infinit loop is created. This was found testing an arm-none-eabi toolchain built with x86_64-w64-mingw32. If the same source tree is built with i686-w64-mingw32, everything appears to be working correctly. Signed-off-by: Torbjörn SVENSSON Co-Authored-By: Yvan ROUX --- libctf/ctf-types.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index c20ff825d9a..058b647ba9a 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -233,7 +233,8 @@ ctf_member_next (ctf_dict_t *fp, ctf_id_t type, ctf_next_t **it, end_iter: ctf_next_destroy (i); *it = NULL; - return ctf_set_errno (ofp, ECTF_NEXT_END); + ctf_set_errno (ofp, ECTF_NEXT_END); + return -1; } /* Iterate over the members of an ENUM. We pass the string name and associated -- 2.25.1