CVE-2014-0172.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From 7f1eec317db79627b473c5b149a22a1b20d1f68f Mon Sep 17 00:00:00 2001
  2. From: Mark Wielaard <mjw@redhat.com>
  3. Date: Wed, 9 Apr 2014 11:33:23 +0200
  4. Subject: [PATCH] CVE-2014-0172 Check for overflow before calling malloc to
  5. uncompress data.
  6. https://bugzilla.redhat.com/show_bug.cgi?id=1085663
  7. Reported-by: Florian Weimer <fweimer@redhat.com>
  8. Signed-off-by: Mark Wielaard <mjw@redhat.com>
  9. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
  10. index 79daeac..34ea373 100644
  11. --- a/libdw/dwarf_begin_elf.c
  12. +++ b/libdw/dwarf_begin_elf.c
  13. @@ -1,5 +1,5 @@
  14. /* Create descriptor from ELF descriptor for processing file.
  15. - Copyright (C) 2002-2011 Red Hat, Inc.
  16. + Copyright (C) 2002-2011, 2014 Red Hat, Inc.
  17. This file is part of elfutils.
  18. Written by Ulrich Drepper <drepper@redhat.com>, 2002.
  19. @@ -282,6 +282,12 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
  20. memcpy (&size, data->d_buf + 4, sizeof size);
  21. size = be64toh (size);
  22. + /* Check for unsigned overflow so malloc always allocated
  23. + enough memory for both the Elf_Data header and the
  24. + uncompressed section data. */
  25. + if (unlikely (sizeof (Elf_Data) + size < size))
  26. + break;
  27. +
  28. Elf_Data *zdata = malloc (sizeof (Elf_Data) + size);
  29. if (unlikely (zdata == NULL))
  30. break;
  31. --
  32. 1.9.2