From 998a4f589d68503f79695f180fdf1742eeb0a39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Date: Wed, 13 Sep 2023 11:02:36 +0200 Subject: libctf: Sanitize error types for PR 30836 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made sure there is no implicit conversion between signed and unsigned return value for functions setting the ctf_errno value. An example of the problem is that in ctf_member_next, the "offset" value is either 0L or (ctf_id_t)-1L, but it should have been 0L or -1L. The issue was discovered while building a 64 bit ld binary to be executed on the Windows platform. Example object file that demonstrates the issue is attached in the PR. libctf/ Affected functions adjusted. Signed-off-by: Torbjörn SVENSSON Co-Authored-By: Yvan ROUX --- libctf/ctf-link.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'libctf/ctf-link.c') diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index 9babec2..27d11c9 100644 --- a/libctf/ctf-link.c +++ b/libctf/ctf-link.c @@ -243,8 +243,7 @@ ctf_link_lazy_open (ctf_dict_t *fp, ctf_link_input_t *input) #else ctf_err_warn (fp, 0, ECTF_NEEDSBFD, _("cannot open %s lazily"), input->clin_filename); - ctf_set_errno (fp, ECTF_NEEDSBFD); - return -1; + return ctf_set_errno (fp, ECTF_NEEDSBFD); #endif /* Having no CTF sections is not an error. We just don't need to do @@ -257,8 +256,7 @@ ctf_link_lazy_open (ctf_dict_t *fp, ctf_link_input_t *input) ctf_err_warn (fp, 0, err, _("opening CTF %s failed"), input->clin_filename); - ctf_set_errno (fp, err); - return -1; + return ctf_set_errno (fp, err); } if ((count = ctf_archive_count (input->clin_arc)) == 0) @@ -680,8 +678,7 @@ ctf_link_deduplicating_count_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names, { ctf_err_warn (fp, 0, err, _("iteration error counting deduplicating " "CTF link inputs")); - ctf_set_errno (fp, err); - return -1; + return ctf_set_errno (fp, err); } if (!count) @@ -1355,8 +1352,7 @@ ctf_link_empty_outputs (ctf_dict_t *fp) { fp->ctf_flags &= ~LCTF_LINKING; ctf_err_warn (fp, 1, err, _("iteration error removing old outputs")); - ctf_set_errno (fp, err); - return -1; + return ctf_set_errno (fp, err); } return 0; } @@ -1536,8 +1532,7 @@ ctf_link (ctf_dict_t *fp, int flags) { fp->ctf_flags &= ~LCTF_LINKING; ctf_err_warn (fp, 1, err, _("iteration error creating empty CUs")); - ctf_set_errno (fp, err); - return -1; + return ctf_set_errno (fp, err); } } -- cgit v1.1