From: Andrey Vagin <avagin@openvz.org>
To: util-linux@vger.kernel.org
Cc: Karel Zak <kzak@redhat.com>, Andrew Vagin <avagin@openvz.org>
Subject: [PATCH] hexdump: don't access hex after freeing it
Date: Fri, 27 Dec 2013 17:45:06 +0400 [thread overview]
Message-ID: <1388151906-9057-1-git-send-email-avagin@openvz.org> (raw)
From: Andrew Vagin <avagin@openvz.org>
==20209== Invalid read of size 4
==20209== at 0x923C: main (hexdump.c:202)
==20209== Address 0x49af034 is 12 bytes inside a block of size 32 free'd
==20209== at 0x48348B8: free (vg_replace_malloc.c:427)
==20209== by 0x923B: main (hexdump.c:200)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
---
text-utils/hexdump.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index 1806077..cebd676 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -165,11 +165,13 @@ int main(int argc, char **argv)
{
struct list_head *p;
struct hexdump_fs *tfs;
+ int ret;
char *c;
struct hexdump *hex = malloc (sizeof (struct hexdump));
hex->length = -1;
hex->skip = 0;
+ hex->exitval = 0;
INIT_LIST_HEAD(&hex->fshead);
setlocale(LC_ALL, "");
@@ -197,8 +199,9 @@ int main(int argc, char **argv)
next(argv, hex);
display(hex);
+ ret = hex->exitval;
hex_free(hex);
- return hex->exitval;
+ return ret;
}
void hex_free(struct hexdump *hex)
--
1.8.4.2
next reply other threads:[~2013-12-27 13:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-27 13:45 Andrey Vagin [this message]
2014-01-06 13:01 ` [PATCH] hexdump: don't access hex after freeing it Karel Zak
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=1388151906-9057-1-git-send-email-avagin@openvz.org \
--to=avagin@openvz.org \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.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