From: "andrzej zaborowski" <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] New Qemu Crash found with evidence of memory corruption
Date: Tue, 18 Dec 2007 02:08:50 +0100 [thread overview]
Message-ID: <fb249edb0712171708j763de0a0ndaae035d7ab5949f@mail.gmail.com> (raw)
In-Reply-To: <je63yywo0p.fsf@sykes.suse.de>
On 16/12/2007, Andreas Schwab <schwab@suse.de> wrote:
> "Alexey Eremenko" <alexey.eremenko@qumranet.com> writes:
>
> > ======================================================
> > The error seems to be in Qemu's readline.c:
> >
> > if (idx == TERM_MAX_CMDS) {
> > /* Need to get one free slot */
> > free(term_history[0]); <-- Here is the error.
> > memcpy(term_history, &term_history[1],
> > &term_history[TERM_MAX_CMDS] - &term_history[1]);
> > term_history[TERM_MAX_CMDS - 1] = NULL;
> > idx = TERM_MAX_CMDS - 1;
> > }
> >
>
> Please try this:
>
> --- readline.c 09 Dez 2007 19:27:48 +0100 1.7
> +++ readline.c 16 Dez 2007 18:22:43 +0100
> @@ -267,7 +267,7 @@ static void term_hist_add(const char *cm
> new_entry = hist_entry;
> /* Put this entry at the end of history */
> memmove(&term_history[idx], &term_history[idx + 1],
> - &term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);
> + (TERM_MAX_CMDS - idx + 1) * sizeof(char *));
> term_history[TERM_MAX_CMDS - 1] = NULL;
> for (; idx < TERM_MAX_CMDS; idx++) {
> if (term_history[idx] == NULL)
> @@ -280,7 +280,7 @@ static void term_hist_add(const char *cm
> /* Need to get one free slot */
> free(term_history[0]);
> memcpy(term_history, &term_history[1],
> - &term_history[TERM_MAX_CMDS] - &term_history[1]);
> + (TERM_MAX_CMDS - 1) * sizeof(char *));
> term_history[TERM_MAX_CMDS - 1] = NULL;
> idx = TERM_MAX_CMDS - 1;
> }
This is correct. I remember submitting the exact same fix about a year
and a half ago in the patch to save/restore monitor history between
sessions. By the way would there be interest to have such feature in
mainline cvs?
Regards
prev parent reply other threads:[~2007-12-18 1:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-16 14:51 [Qemu-devel] New Qemu Crash found with evidence of memory corruption Alexey Eremenko
2007-12-16 17:24 ` Andreas Schwab
2007-12-17 8:11 ` [Qemu-devel] New Qemu Crash found with evidence of memorycorruption Alexey Eremenko
2007-12-18 1:08 ` andrzej zaborowski [this message]
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=fb249edb0712171708j763de0a0ndaae035d7ab5949f@mail.gmail.com \
--to=balrogg@gmail.com \
--cc=qemu-devel@nongnu.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 NNTP newsgroup(s).