Fix illegal memory accesses in readelf when parsing a corrupt binary.
[binutils-gdb.git] / binutils / rddbg.c
index ea8161ba67428cdd8d7e7a598b717983103c4d8b..1d8c4471887c29877ef23d021b05bb5b22ca9c61 100644 (file)
@@ -1,5 +1,5 @@
 /* rddbg.c -- Read debugging information into a generic form.
-   Copyright (C) 1995-2014 Free Software Foundation, Inc.
+   Copyright (C) 1995-2017 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GNU Binutils.
@@ -299,7 +299,10 @@ read_symbol_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount,
          *pfound = TRUE;
 
          s = i.name;
+         if (s == NULL || strlen (s) < 1)
+           return FALSE;
          f = NULL;
+
          while (s[strlen (s) - 1] == '\\'
                 && ps + 1 < symend)
            {