summaryrefslogtreecommitdiffstats
path: root/libelf/gelf_getnote.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2014-11-14 17:05:08 +0100
committerMark Wielaard <[email protected]>2014-11-14 17:05:08 +0100
commitdf2fe50346828e8229185d297ac803428c727d2a (patch)
treefb7e47e80cc1b9b2d59bf2585251f89c2c4b7155 /libelf/gelf_getnote.c
parent2f8e4d338323f225a117b34f84155917a7e49271 (diff)
libelf: gelf_getnote check for offset overflow.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/gelf_getnote.c')
-rw-r--r--libelf/gelf_getnote.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libelf/gelf_getnote.c b/libelf/gelf_getnote.c
index 1a368553..8bb78c16 100644
--- a/libelf/gelf_getnote.c
+++ b/libelf/gelf_getnote.c
@@ -1,5 +1,5 @@
/* Get note information at the supplied offset.
- Copyright (C) 2007 Red Hat, Inc.
+ Copyright (C) 2007, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -62,7 +62,8 @@ gelf_getnote (data, offset, result, name_offset, desc_offset)
/* The data is already in the correct form. Just make sure the
offset is OK. */
- if (unlikely (offset + sizeof (GElf_Nhdr) > data->d_size))
+ if (unlikely (offset > data->d_size
+ || data->d_size - offset < sizeof (GElf_Nhdr)))
{
__libelf_seterrno (ELF_E_OFFSET_RANGE);
offset = 0;