summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2006-12-24 09:45:10 +0000
committerjkoshy <jkoshy@FreeBSD.org>2006-12-24 09:45:10 +0000
commit4df7e1dc11c7fc942b4c481d3bdbfd828373416a (patch)
treed01ab57ebc83014fbfb41f718c964be4c79f8aeb /lib
parentfd771edb776d00ec8549c44d8f2b9fe1567517e9 (diff)
downloadFreeBSD-src-4df7e1dc11c7fc942b4c481d3bdbfd828373416a.zip
FreeBSD-src-4df7e1dc11c7fc942b4c481d3bdbfd828373416a.tar.gz
Correct a logic error.
Diffstat (limited to 'lib')
-rw-r--r--lib/libelf/libelf_xlate.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/libelf/libelf_xlate.c b/lib/libelf/libelf_xlate.c
index 65a47b5..06ef8d0 100644
--- a/lib/libelf/libelf_xlate.c
+++ b/lib/libelf/libelf_xlate.c
@@ -92,8 +92,18 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding,
return (NULL);
}
- cnt = src->d_size / msz;
- dsz = cnt * fsz;
+ /*
+ * Determine the number of objects that need to be converted, and
+ * the space required for the converted objects in the destination
+ * buffer.
+ */
+ if (direction == ELF_TOMEMORY) {
+ cnt = src->d_size / fsz;
+ dsz = cnt * msz;
+ } else {
+ cnt = src->d_size / msz;
+ dsz = cnt * fsz;
+ }
if (dst->d_size < dsz) {
LIBELF_SET_ERROR(DATA, 0);
@@ -107,12 +117,9 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding,
/*
* Check for overlapping buffers. Note that db == sb is
- * allowed, in which case the source buffer must also be large
- * enough for `n' target objects. For file to native
- * conversions, an in-place conversion is not always possible.
+ * allowed.
*/
- if ((db == sb && dsz < src->d_size) ||
- (db != sb && de > sb && se > db)) {
+ if (db != sb && de > sb && se > db) {
LIBELF_SET_ERROR(DATA, 0);
return (NULL);
}
@@ -124,7 +131,7 @@ _libelf_xlate(Elf_Data *dst, const Elf_Data *src, unsigned int encoding,
}
dst->d_type = src->d_type;
- dst->d_size = cnt * fsz;
+ dst->d_size = dsz;
if (db == sb && encoding == LIBELF_PRIVATE(byteorder) &&
fsz == msz)
OpenPOWER on IntegriCloud