cipher: Avoid signed divisions in idea.c
authorWerner Koch <wk@gnupg.org>
Fri, 8 Nov 2013 16:21:02 +0000 (17:21 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 8 Nov 2013 16:21:02 +0000 (17:21 +0100)
* cipher/idea.c (mul_inv): Use unsigned division.
--

Reported-by: Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com>
  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.

Signed-off-by: Werner Koch <wk@gnupg.org>
cipher/idea.c

index 7d91a9a..14234cf 100644 (file)
@@ -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;