From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR29170, divide by zero displaying fuzzed .debug_names
Date: Tue, 24 May 2022 13:48:33 +0930 [thread overview]
Message-ID: <YoxcmXL0w3hAURf0@squeak.grove.modra.org> (raw)
PR 29170
* dwarf.c (display_debug_names): Don't attempt to display bucket
clashes when bucket count is zero.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c855972a12f..d820c21527f 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -10149,32 +10149,35 @@ display_debug_names (struct dwarf_section *section, void *file)
bucket_count),
buckets_filled, (unsigned long) bucket_count);
- uint32_t hash_prev = 0;
- size_t hash_clash_count = 0;
- size_t longest_clash = 0;
- size_t this_length = 0;
- size_t hashi;
- for (hashi = 0; hashi < name_count; hashi++)
- {
- const uint32_t hash_this = hash_table_hashes[hashi];
-
- if (hashi > 0)
+ if (bucket_count != 0)
+ {
+ uint32_t hash_prev = 0;
+ size_t hash_clash_count = 0;
+ size_t longest_clash = 0;
+ size_t this_length = 0;
+ size_t hashi;
+ for (hashi = 0; hashi < name_count; hashi++)
{
- if (hash_prev % bucket_count == hash_this % bucket_count)
+ const uint32_t hash_this = hash_table_hashes[hashi];
+
+ if (hashi > 0)
{
- ++hash_clash_count;
- ++this_length;
- longest_clash = MAX (longest_clash, this_length);
+ if (hash_prev % bucket_count == hash_this % bucket_count)
+ {
+ ++hash_clash_count;
+ ++this_length;
+ longest_clash = MAX (longest_clash, this_length);
+ }
+ else
+ this_length = 0;
}
- else
- this_length = 0;
+ hash_prev = hash_this;
}
- hash_prev = hash_this;
+ printf (_("Out of %lu items there are %zu bucket clashes"
+ " (longest of %zu entries).\n"),
+ (unsigned long) name_count, hash_clash_count, longest_clash);
+ assert (name_count == buckets_filled + hash_clash_count);
}
- printf (_("Out of %lu items there are %zu bucket clashes"
- " (longest of %zu entries).\n"),
- (unsigned long) name_count, hash_clash_count, longest_clash);
- assert (name_count == buckets_filled + hash_clash_count);
struct abbrev_lookup_entry
{
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-05-24 4:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=YoxcmXL0w3hAURf0@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/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).