All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: Jan Ondrej <ondrejj@salstar.sk>,
	Glauber Costa <glommer@redhat.com>,
	Paolo Bonzini <bonzini@gnu.org>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Fix checksum writing in signboot.sh
Date: Sun, 02 Aug 2009 13:04:01 +0300	[thread overview]
Message-ID: <4A756491.6020004@redhat.com> (raw)
In-Reply-To: <1249120111-31757-1-git-send-email-agraf@suse.de>

On 08/01/2009 12:48 PM, Alexander Graf wrote:
> The printf command takes an octal value after \, so we have to convert
> our decimal representation to octal first and then write it.
>
> This unbreaks extboot signing. Multiboot wasn't affected yet because
> the checksum was<  8.
>
> Spotted and first patch by Glauber Costa<glommer@redhat.com>.
> Printf idea by Paolo Bonzini<bonzini@gnu.org>.
>
> Signed-off-by: Alexander Graf<agraf@suse.de>
> CC: Glauber Costa<glommer@redhat.com>
> CC: Paolo Bonzini<bonzini@gnu.org>
> CC: Jan Ondrej<ondrejj@salstar.sk>
> ---
>   pc-bios/optionrom/signrom.sh |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
> index 4322811..975b27d 100755
> --- a/pc-bios/optionrom/signrom.sh
> +++ b/pc-bios/optionrom/signrom.sh
> @@ -39,7 +39,8 @@ done
>
>   sum=$(( $sum % 256 ))
>   sum=$(( 256 - $sum ))
> +sum_octal=$( printf "%o" $sum )
>
>   # and write the output file
>   cp "$1" "$2"
> -printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null
> +printf "\\$sum_octal" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null
>    

While the patch is good, the code is unreadable.  Can we mandate python 
for such tricks?

    f = file(out, 'r+b')
    f.seek(size)
    f.write(chr(sum))

sh is not a sane programming language.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2009-08-02 10:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-01  9:48 [Qemu-devel] [PATCH] Fix checksum writing in signboot.sh Alexander Graf
2009-08-02 10:04 ` Avi Kivity [this message]
2009-08-02 10:25   ` [Qemu-devel] " Filip Navara
2009-08-02 11:15     ` Avi Kivity
2009-08-02 11:58       ` Alexander Graf
2009-08-02 12:21         ` Avi Kivity
2009-08-02 21:29         ` [Qemu-devel] " Sebastian Herbszt
2009-08-03  2:30         ` [Qemu-devel] " Anthony Liguori
2009-08-03  6:12           ` Paolo Bonzini
2009-08-03 12:55           ` Avi Kivity

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=4A756491.6020004@redhat.com \
    --to=avi@redhat.com \
    --cc=agraf@suse.de \
    --cc=bonzini@gnu.org \
    --cc=glommer@redhat.com \
    --cc=ondrejj@salstar.sk \
    --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.