From: Anthony Liguori <anthony@codemonkey.ws>
To: Avi Kivity <avi@redhat.com>
Cc: qemu-devel@nongnu.org, Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] optionrom: fix bugs in signrom.sh
Date: Sun, 21 Nov 2010 09:19:42 -0600 [thread overview]
Message-ID: <4CE9388E.4050804@codemonkey.ws> (raw)
In-Reply-To: <1289917997-27429-1-git-send-email-avi@redhat.com>
On 11/16/2010 08:33 AM, Avi Kivity wrote:
> signrom.sh has multiple bugs:
>
> - the last byte is considered when calculating the existing checksum, but not
> when computing the correction
> - apprently the 'expr' expression overflows and produces incorrect results with
> larger roms
> - if the checksum happened to be zero, we calculated the correction byte to be
> 256
>
> Instead of rewriting this in half a line of python, this patch fixes the bugs.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> pc-bios/optionrom/signrom.sh | 7 +++----
> 1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
> index 975b27d..9dc5c63 100755
> --- a/pc-bios/optionrom/signrom.sh
> +++ b/pc-bios/optionrom/signrom.sh
> @@ -31,14 +31,13 @@ x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
> size=$(( $x * 512 - 1 ))
>
> # now get the checksum
> -nums=`od -A n -t u1 -v "$1"`
> +nums=`od -A n -t u1 -v -N $size "$1"`
> for i in ${nums}; do
> # add each byte's value to sum
> - sum=`expr $sum + $i`
> + sum=`expr \( $sum + $i \) % 256`
> done
>
> -sum=$(( $sum % 256 ))
> -sum=$(( 256 - $sum ))
> +sum=$(( (256 - $sum) % 256 ))
> sum_octal=$( printf "%o" $sum )
>
> # and write the output file
>
WARNING: multiple messages have this Message-ID (diff)
From: Anthony Liguori <anthony@codemonkey.ws>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] optionrom: fix bugs in signrom.sh
Date: Sun, 21 Nov 2010 09:19:42 -0600 [thread overview]
Message-ID: <4CE9388E.4050804@codemonkey.ws> (raw)
In-Reply-To: <1289917997-27429-1-git-send-email-avi@redhat.com>
On 11/16/2010 08:33 AM, Avi Kivity wrote:
> signrom.sh has multiple bugs:
>
> - the last byte is considered when calculating the existing checksum, but not
> when computing the correction
> - apprently the 'expr' expression overflows and produces incorrect results with
> larger roms
> - if the checksum happened to be zero, we calculated the correction byte to be
> 256
>
> Instead of rewriting this in half a line of python, this patch fixes the bugs.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> pc-bios/optionrom/signrom.sh | 7 +++----
> 1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
> index 975b27d..9dc5c63 100755
> --- a/pc-bios/optionrom/signrom.sh
> +++ b/pc-bios/optionrom/signrom.sh
> @@ -31,14 +31,13 @@ x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
> size=$(( $x * 512 - 1 ))
>
> # now get the checksum
> -nums=`od -A n -t u1 -v "$1"`
> +nums=`od -A n -t u1 -v -N $size "$1"`
> for i in ${nums}; do
> # add each byte's value to sum
> - sum=`expr $sum + $i`
> + sum=`expr \( $sum + $i \) % 256`
> done
>
> -sum=$(( $sum % 256 ))
> -sum=$(( 256 - $sum ))
> +sum=$(( (256 - $sum) % 256 ))
> sum_octal=$( printf "%o" $sum )
>
> # and write the output file
>
next prev parent reply other threads:[~2010-11-21 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 14:33 [PATCH] optionrom: fix bugs in signrom.sh Avi Kivity
2010-11-16 14:33 ` [Qemu-devel] " Avi Kivity
2010-11-21 15:19 ` Anthony Liguori [this message]
2010-11-21 15:19 ` Anthony Liguori
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=4CE9388E.4050804@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.