<< | Thread Index | >> ]    [ << | Date Index | >> ]

Subject: 64bit bug [fix included...]
From: Herbert Valerio Riedel <hvr,AT,hvrlab,DOT,org>
Date: Thu, 29 Mar 2001 09:53:54 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

...following diff fixes operation on linux/axp...
(sizeof (unsigned long) != sizeof (uint32) on axp!!!!)

BTW! -- you should change the other unsigned long's when they are used as
crc holding vars too!

changing most long's to a fixed int size would be a good idea in general
to improve portability/readability/correctness  :-)

...

e.g. just grep for longs:

ciped.c:typedef unsigned long crc;
crc32.c:static unsigned long crc32_tab[] = {
crc32.c:unsigned long crc32(const unsigned char *s, unsigned int len)
crc32.c:  unsigned long crc32val = 0;

and especially cipe.h !!!

cipe.h:    unsigned long       magic;
cipe.h:    unsigned long       sockshost;
cipe.h:    unsigned long       magic;
cipe.h:    unsigned long       sockshost;
cipe.h:    unsigned long       magic;
cipe.h:    unsigned long       magic;
cipe.h:    unsigned long       magic;
cipe.h:#define timeout_t unsigned long
cipe.h:#define timeout_t long
cipe.h:    unsigned long       tmo_keyxchg;
cipe.h:    unsigned long       tmo_keylife;
cipe.h:    unsigned long       timekx;
cipe.h:    unsigned long       timeskey;
cipe.h:    unsigned long       timerkey;
cipe.h:#define LOCK_PRINTK unsigned long flags; 
spin_lock_irqsave(&cipe_printk_lock, flags)

- --- encaps.c.orig     Thu Mar 29 09:27:42 2001
+++ encaps.c    Wed Jul 14 22:46:26 2021
@@ -209,7 +209,7 @@
     (*len)+=p+5;
     /* set type and crc */
     *(buf+(*len)-5)=typ|(p<<4);
- -    *((unsigned long *)(buf+(*len)-4))=
+    *((__u32*)(buf+(*len)-4))=
        htonl(crc32(buf+blockSize, (*len)-blockSize-4));

     dprintk(DEB_CRYPT, (KERN_INFO "%s: encrypt typ %d pad %d len %d\n",
@@ -228,7 +228,7 @@
     }
     cbc_dec(buf, *len, ((*buf)&0x80) ? &c->rkey_d : &c->key_d);
     (*len)-=blockSize;
- -    if (*((unsigned long *)(buf+(*len)-4)) != htonl(crc32(buf, (*len)-4))) 
{
+    if (*((__u32*)(buf+(*len)-4)) != htonl(crc32(buf, (*len)-4))) {
        dprintk(DEB_CRYPT, (KERN_INFO "%s: decrypt CRC error\n",
                            c->dev->name));
        return TW_ERROR;

- -- 
Herbert Valerio Riedel      /     Finger hvr,AT,gnu,DOT,org for GnuPG Public 
Key
GnuPG Key Fingerprint: AC2A CD57 A5C8 A1CB 0A18  DA95 CB0B DB23 60B6 16F5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6wubASYHgZIg/QUIRAofPAJsEyDP7v0CIqH3ViOp4x6/wuC0leACfW9uw
FF97Jok7u9Ao++k+So9c7Gs=
=Awgh
-----END PGP SIGNATURE-----





<< | Thread Index | >> ]    [ << | Date Index | >> ]