From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXYGH-0003ev-KS for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:25:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXYGC-0003d9-S5 for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:25:52 -0400 Received: from [199.232.76.173] (port=56399 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXYGA-0003cW-Cr for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:25:47 -0400 Received: from mail-ew0-f210.google.com ([209.85.219.210]:58119) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXYG9-0004SZ-Nm for qemu-devel@nongnu.org; Sun, 02 Aug 2009 06:25:45 -0400 Received: by ewy6 with SMTP id 6so594413ewy.34 for ; Sun, 02 Aug 2009 03:25:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4A756491.6020004@redhat.com> References: <1249120111-31757-1-git-send-email-agraf@suse.de> <4A756491.6020004@redhat.com> Date: Sun, 2 Aug 2009 12:25:44 +0200 Message-ID: <5b31733c0908020325k3e035b91n3b0089a2f865de3@mail.gmail.com> Subject: Re: [Qemu-devel] Re: [PATCH] Fix checksum writing in signboot.sh From: Filip Navara Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Paolo Bonzini , Glauber Costa , Jan Ondrej , Alexander Graf , qemu-devel@nongnu.org On Sun, Aug 2, 2009 at 12:04 PM, Avi Kivity wrote: > 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< =A08. >> >> 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 >> --- >> =A0pc-bios/optionrom/signrom.sh | =A0 =A03 ++- >> =A01 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 >> >> =A0sum=3D$(( $sum % 256 )) >> =A0sum=3D$(( 256 - $sum )) >> +sum_octal=3D$( printf "%o" $sum ) >> >> =A0# and write the output file >> =A0cp "$1" "$2" >> -printf "\\$sum" | dd of=3D"$2" bs=3D1 count=3D1 seek=3D$size conv=3Dnot= runc >> 2>/dev/null >> +printf "\\$sum_octal" | dd of=3D"$2" bs=3D1 count=3D1 seek=3D$size conv= =3Dnotrunc >> 2>/dev/null >> > > While the patch is good, the code is unreadable. =A0Can we mandate python= for > such tricks? No, please, no! Throwing additional tools at the problem is only going to make it worse for Windows users. I'm not happy with using sh script as it already added dependency on coreutils, but at least that's easy to install. Python is a nightmare compared to that. BTW, for years in ReactOS we had a way to build host tools with host CC and these tools were written in plain ordinary C. This worked great for both Windows and Linux builds and also for cross-compiling. Best regards, Filip Navara