]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Bounds check Dwarf_Fileinfo file number in dwfl_lineinfo.
authorMark Wielaard <mjw@redhat.com>
Tue, 5 May 2015 08:05:01 +0000 (10:05 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 12 May 2015 14:34:39 +0000 (16:34 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c30

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/dwfl_lineinfo.c

index d9922b4a2763fd78a2621ab32069f1197b30bc7e..de76378d4839d5ab9986d1b614a84bd41487ea58 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-05  Mark Wielaard  <mjw@redhat.com>
+
+       * dwfl_lineinfo.c (dwfl_lineinfo): Check info->file is valid.
+
 2015-05-06  Roland McGrath  <roland@hack.frob.com>
 
        * dwfl_error.c (struct msgtable): Break type definition out of
index dfb27d827694ef6f637a50c3d82f5bc86699c0d9..7ddbfb07f1d05c621f8a34d5300234443edc1b77 100644 (file)
@@ -1,5 +1,5 @@
 /* Get information from a source line record returned by libdwfl.
-   Copyright (C) 2005-2010 Red Hat, Inc.
+   Copyright (C) 2005-2010, 2015 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -46,6 +46,12 @@ dwfl_lineinfo (Dwfl_Line *line, Dwarf_Addr *addr, int *linep, int *colp,
   if (colp != NULL)
     *colp = info->column;
 
+  if (unlikely (info->file >= info->files->nfiles))
+    {
+      __libdwfl_seterrno (DWFL_E (LIBDW, DWARF_E_INVALID_DWARF));
+      return NULL;
+    }
+
   struct Dwarf_Fileinfo_s *file = &info->files->info[info->file];
   if (mtime != NULL)
     *mtime = file->mtime;