From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] libelf: Copy over any leftover data from src to dest in elf_cvt_note.
Date: Mon, 24 Nov 2014 00:20:16 +0100 [thread overview]
Message-ID: <1416784816-32626-1-git-send-email-mjw@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]
If any data is left then the data is likely part of the truncated note
name/desc. This probably means the note is corrupted, but it is better
to have the actual data in dest instead of random uninitialized memory.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libelf/ChangeLog | 5 +++++
libelf/note_xlate.h | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index b21714e..8a11563 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-23 Mark Wielaard <mjw@redhat.com>
+
+ * note_xlate.h (elf_cvt_note): Copy over any leftover data if
+ src != dest. The data is probably part of truncated name/desc.
+
2014-11-22 Mark Wielaard <mjw@redhat.com>
* elf_getphdrnum.c (elf_getphdrnum): Sanity check the
diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h
index 8187e88..aa730bc 100644
--- a/libelf/note_xlate.h
+++ b/libelf/note_xlate.h
@@ -1,5 +1,5 @@
/* Conversion functions for notes.
- Copyright (C) 2007, 2009 Red Hat, Inc.
+ Copyright (C) 2007, 2009, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -56,4 +56,9 @@ elf_cvt_note (void *dest, const void *src, size_t len, int encode)
src += namesz + descsz;
dest += namesz + descsz;
}
+
+ /* Copy opver any leftover data unconcerted. Probably part of
+ truncated name/desc data. */
+ if (len > 0 && src != dest)
+ memcpy (dest, src, len);
}
--
1.9.3
reply other threads:[~2014-11-23 23:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416784816-32626-1-git-send-email-mjw@redhat.com \
--to=mjw@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).