summaryrefslogtreecommitdiffstats
path: root/lib/libelf
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2008-03-03 04:29:25 +0000
committerjkoshy <jkoshy@FreeBSD.org>2008-03-03 04:29:25 +0000
commit35a6571045781ec1f9724661441fad079832df2e (patch)
treea2d873821de07a2b38097c49ce23045a561a1df0 /lib/libelf
parent0be629ebec2f65276fcc725a5ffca28ef61b2cde (diff)
downloadFreeBSD-src-35a6571045781ec1f9724661441fad079832df2e.zip
FreeBSD-src-35a6571045781ec1f9724661441fad079832df2e.tar.gz
- Fix an off-by-one bug in _libelf_insert_section(). [1]
- Update (c) years. Submitted by: kaiw [1]
Diffstat (limited to 'lib/libelf')
-rw-r--r--lib/libelf/elf_update.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c
index 57b432e..64a38ea 100644
--- a/lib/libelf/elf_update.c
+++ b/lib/libelf/elf_update.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006 Joseph Koshy
+ * Copyright (c) 2006-2008 Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -246,13 +246,19 @@ _libelf_insert_section(Elf *e, Elf_Scn *s)
tmin = t->s_offset;
tmax = tmin + t->s_size;
- /* check if there is an overlap */
- if (tmax < smin) {
+ if (tmax <= smin) {
+ /*
+ * 't' lies entirely before 's': ...| t |...| s |...
+ */
prevt = t;
continue;
- } else if (smax < tmin)
+ } else if (smax <= tmin)
+ /*
+ * 's' lies entirely before 't', and after 'prevt':
+ * ...| prevt |...| s |...| t |...
+ */
break;
- else {
+ else { /* 's' and 't' overlap. */
LIBELF_SET_ERROR(LAYOUT, 0);
return (0);
}
OpenPOWER on IntegriCloud