public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: dwz@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>, Tom de Vries <tdevries@suse.de>,
	Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] Fix UBSAN reported for Libreoffice so files.
Date: Mon, 15 Mar 2021 08:48:09 +0100	[thread overview]
Message-ID: <7100560d-5973-8d34-c486-187c7dda21af@suse.cz> (raw)

Fixes:

dwz.c:9041:28: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
     #0 0x405ad3 in bitvector_bit_p /home/marxin/Programming/dwz/dwz.c:9041
     #1 0x405ad3 in create_import_tree /home/marxin/Programming/dwz/dwz.c:9528
     #2 0x405ad3 in dwz /home/marxin/Programming/dwz/dwz.c:15445
     #3 0x407517 in dwz_files /home/marxin/Programming/dwz/dwz.c:16871
     #4 0x407517 in main /home/marxin/Programming/dwz/dwz.c:16985
     #5 0x7ffff6a8eb24 in __libc_start_main ../csu/libc-start.c:332
     #6 0x4086dd in _start (/home/marxin/Programming/dwz/dwz+0x4086dd)

dwz.c:9032:21: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
     #0 0x405a83 in bitvector_set_bit /home/marxin/Programming/dwz/dwz.c:9032
     #1 0x405a83 in create_import_tree /home/marxin/Programming/dwz/dwz.c:9530
     #2 0x405a83 in dwz /home/marxin/Programming/dwz/dwz.c:15445
     #3 0x407517 in dwz_files /home/marxin/Programming/dwz/dwz.c:16871
     #4 0x407517 in main /home/marxin/Programming/dwz/dwz.c:16985
     #5 0x7ffff6a8eb24 in __libc_start_main ../csu/libc-start.c:332
     #6 0x4086dd in _start (/home/marxin/Programming/dwz/dwz+0x4086dd)
---
  dwz.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dwz.c b/dwz.c
index 5975cc7..1928262 100644
--- a/dwz.c
+++ b/dwz.c
@@ -9029,7 +9029,7 @@ bitvector_set_bit (BITVECTOR_TYPE *vector, unsigned idx)
  {
    unsigned div = idx / (sizeof (BITVECTOR_TYPE) * 8);
    unsigned mod = idx % (sizeof (BITVECTOR_TYPE) * 8);
-  vector[div] |= (1 << mod);
+  vector[div] |= (1U << mod);
  }
  
  /* Test bit IDX in bitvector VECTOR.  */
@@ -9038,7 +9038,7 @@ bitvector_bit_p (BITVECTOR_TYPE *vector, unsigned idx)
  {
    unsigned div = idx / (sizeof (BITVECTOR_TYPE) * 8);
    unsigned mod = idx % (sizeof (BITVECTOR_TYPE) * 8);
-  return (vector[div] & (1 << mod)) != 0;
+  return (vector[div] & (1U << mod)) != 0;
  }
  
  /* Clear at least bits [A, B] in VECTOR, possibly more.  */
-- 
2.30.1


             reply	other threads:[~2021-03-15  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15  7:48 Martin Liška [this message]
2021-03-15 10:20 ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7100560d-5973-8d34-c486-187c7dda21af@suse.cz \
    --to=mliska@suse.cz \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    --cc=mark@klomp.org \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).