From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXXsU-0001Cx-5L for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:01:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXXsP-0001B2-BS for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:01:17 -0400 Received: from [199.232.76.173] (port=36299 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXXsP-0001Ay-5W for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:01:13 -0400 Message-ID: <4A756491.6020004@redhat.com> Date: Sun, 02 Aug 2009 13:04:01 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1249120111-31757-1-git-send-email-agraf@suse.de> In-Reply-To: <1249120111-31757-1-git-send-email-agraf@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Fix checksum writing in signboot.sh List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Jan Ondrej , Glauber Costa , Paolo Bonzini , qemu-devel@nongnu.org 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. > Printf idea by Paolo Bonzini. > > Signed-off-by: Alexander Graf > CC: Glauber Costa > CC: Paolo Bonzini > CC: Jan Ondrej > --- > 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