Signed division in idea.c

Vladimir 'φ-coder/phcoder' Serbinenko phcoder at gmail.com
Fri Nov 8 15:19:14 CET 2013


Hello, all. While compiling in an environment with only libgcc subset
for ARM, I found out that idea.c uses signed divisions:
Reading the code this seems to be unintended. Inlined patch replaces
them with more appropriate unsigned division.


diff --git a/grub-core/lib/libgcrypt/cipher/idea.c
b/grub-core/lib/libgcrypt/cipher/idea.c
index c025c95..3c5578f 100644
--- a/grub-core/lib/libgcrypt/cipher/idea.c
+++ b/grub-core/lib/libgcrypt/cipher/idea.c
@@ -72,8 +72,8 @@ mul_inv( u16 x )

     if( x < 2 )
        return x;
-    t1 = 0x10001L / x;
-    y =  0x10001L % x;
+    t1 = 0x10001UL / x;
+    y =  0x10001UL % x;
     if( y == 1 )
        return (1-t1) & 0xffff;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 291 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20131108/b28ca14c/attachment.sig>


More information about the Gcrypt-devel mailing list