public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libctf: ctf_member_next needs to return (ssize_t)-1 on error
@ 2023-08-24 11:32 Torbjörn SVENSSON
  2023-08-25  2:22 ` Alan Modra
  0 siblings, 1 reply; 44+ messages in thread
From: Torbjörn SVENSSON @ 2023-08-24 11:32 UTC (permalink / raw)
  To: binutils; +Cc: Torbjörn SVENSSON, Yvan ROUX

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 <torbjorn.svensson@foss.st.com>
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
---
 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


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2024-03-12  6:52 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 11:32 [PATCH] libctf: ctf_member_next needs to return (ssize_t)-1 on error Torbjörn SVENSSON
2023-08-25  2:22 ` Alan Modra
2023-08-25 16:53   ` [PATCH v2] " Torbjörn SVENSSON
2023-08-30  8:34     ` Torbjorn SVENSSON
2023-08-30  9:39       ` Alan Modra
2023-09-07 12:10         ` Nick Alcock
2023-09-08 12:58           ` Torbjorn SVENSSON
2023-09-12 14:23             ` Nick Alcock
2023-09-12 18:44               ` Torbjorn SVENSSON
2023-09-13  9:57               ` [PATCH v3] " Torbjörn SVENSSON
2023-09-13 18:37                 ` Nick Alcock
2023-09-13 20:20                   ` Torbjorn SVENSSON
2023-09-20 17:44                     ` Torbjorn SVENSSON
2023-09-26 14:51                     ` Nick Alcock
2023-09-26 17:28                       ` [PATCH v4] " Torbjörn SVENSSON
2023-09-26 17:49                       ` [PATCH v3] " Torbjorn SVENSSON
2023-09-28 16:41                         ` Nick Alcock
2023-09-29 12:11                           ` Torbjorn SVENSSON
2023-10-02 10:57                             ` Nick Alcock
2023-10-03 12:59                               ` Torbjorn SVENSSON
2023-10-03 20:53                                 ` Nick Alcock
2023-10-05  8:39                                   ` [PATCH v5] libctf: Sanitize error types for PR 30836 Torbjörn SVENSSON
2023-10-09 10:27                                     ` Nick Alcock
2023-10-09 14:44                                       ` [PATCH v6] " Torbjörn SVENSSON
2023-10-09 15:11                                         ` [PATCH v7] " Torbjörn SVENSSON
2023-10-11 11:14                                           ` Nick Alcock
2023-10-13 14:01                                           ` [PATCH] libctf: check for problems with error returns Nick Alcock
2023-10-13 18:31                                             ` Torbjorn SVENSSON
2023-10-15 19:18                                               ` Nick Alcock
2023-10-16 12:51                                                 ` [PATCH v8] libctf: Sanitize error types for PR 30836 Torbjörn SVENSSON
2023-10-17 15:15                                                   ` Nick Alcock
2023-10-17 15:35                                                     ` Torbjorn SVENSSON
2023-10-17 18:54                                                       ` [PATCH] libctf: Return CTF_ERR in ctf_type_resolve_unsliced " Torbjörn SVENSSON
2023-10-17 19:40                                                         ` Nick Alcock
2023-10-18  7:40                                                           ` Torbjorn SVENSSON
2023-10-20 17:01                                                             ` Nick Alcock
2023-10-16 13:02                                                 ` [PATCH] libctf: check for problems with error returns Torbjorn SVENSSON
2023-10-17 14:45                                                   ` Nick Alcock
2024-01-30 12:46                                             ` Andreas Schwab
2024-01-30 14:22                                               ` Nick Alcock
2024-01-30 14:27                                                 ` Andreas Schwab
2024-03-09  2:44                                                   ` Sam James
2024-03-11 15:14                                                     ` Nick Alcock
2024-03-12  6:52                                                       ` Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).