public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix infinite loop in is_linked_with_cygwin_dll
Date: Thu, 23 Apr 2020 18:53:22 +0000 (GMT)	[thread overview]
Message-ID: <20200423185322.2756F395B438@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=29514b87281c438543e4fc6ddda245dc194d5677

commit 29514b87281c438543e4fc6ddda245dc194d5677
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Apr 23 12:15:28 2020 -0600

    Fix infinite loop in is_linked_with_cygwin_dll
    
    There were some Windows timeouts after the last merge.  Debugging
    showed that these were caused by an infinite loop in
    is_linked_with_cygwin_dll when reading C:\Windows\SysWOW64\win32u.dll.
    
    This patch fixes the problem by ensuring that the loop always makes
    progress.
    
    gdb/ChangeLog
    2020-04-23  Tom Tromey  <tromey@adacore.com>
    
            * windows-tdep.c (is_linked_with_cygwin_dll): Always update "iter"
            in loop.

Diff:
---
 gdb/ChangeLog      |  5 +++++
 gdb/windows-tdep.c | 17 +++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 145328dda1c..85fa7cf5f76 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-23  Tom Tromey  <tromey@adacore.com>
+
+	* windows-tdep.c (is_linked_with_cygwin_dll): Always update "iter"
+	in loop.
+
 2020-04-23  Luis Machado  <luis.machado@linaro.org>
 
 	* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Use
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index e2b7960829f..153ad132b96 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -1071,18 +1071,19 @@ range [0x%" BFD_VMA_FMT "x, 0x%" BFD_VMA_FMT "x[."),
 
       const gdb_byte *name = &idata_contents[name_va - idata_section_va];
 
-      /* Make sure we don't overshoot the end of the section with the streq.  */
-      if (name + sizeof (CYGWIN_DLL_NAME) > end)
-	continue;
-
-      /* Finally, check if this is the dll name we are looking for.  */
-      if (streq ((const char *) name, CYGWIN_DLL_NAME))
-	return true;
+      /* Make sure we don't overshoot the end of the section with the
+	 streq.  */
+      if (name + sizeof (CYGWIN_DLL_NAME) <= end)
+	{
+	  /* Finally, check if this is the dll name we are looking for.  */
+	  if (streq ((const char *) name, CYGWIN_DLL_NAME))
+	    return true;
+	}
 
       iter += sizeof (pe_import_directory_entry);
     }
 
-    return false;
+  return false;
 }
 
 void _initialize_windows_tdep ();


                 reply	other threads:[~2020-04-23 18:53 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=20200423185322.2756F395B438@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@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).