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

Subject: Re: CIPE on DEC Alpha
From: Olaf Titz <olaf,AT,bigred,DOT,inka,DOT,de>
Date: Sun, 20 Oct 2002 20:05:24 +0200

> Using the kernel data types is great.  It was the crc32.c that was at
> fault.  I believe that it was programmed for DOS 16-bit mode because it
> uses a long int for a 32 bit word.  I havn't seen that since I last

Yes, that code surely originates from the 16 bit world.

The attached patch is in the snapshot starting with tomorrow too. It
really should be correct but if there are more 64-bit traps let me
know. (I've chosen u_int32_t since that's the one type which is
defined both in the kernel and user mode headers, and crc32.c is used
by both.)

Olaf

Index: cipe/cipe.h
===================================================================
RCS file: /home/olaf/common-home/CVSrepos/security/cipe-linux/cipe/cipe.h,v
retrieving revision 1.48
diff -u -r1.48 cipe.h
--- cipe/cipe.h 2002/06/28 23:46:32     1.48
+++ cipe/cipe.h 2002/10/20 17:24:18
@@ -257,6 +257,10 @@
 #define DEV_STATS  enet_statistics
 #endif

+#ifndef LINUX_21
+typedef __u32 u_int32_t;
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,127)
 #define timeout_t unsigned long
 #else
@@ -456,7 +460,7 @@
 #endif /* __KERNEL__ */

 /* crc32.c */
-extern unsigned long crc32(const unsigned char *s, unsigned int len);
+extern u_int32_t crc32(const unsigned char *s, unsigned int len);

 #define MIN(a,b) (((a)<(b))?(a):(b))

Index: cipe/crc32.c
===================================================================
RCS file: /home/olaf/common-home/CVSrepos/security/cipe-linux/cipe/crc32.c,v
retrieving revision 1.3
diff -u -r1.3 crc32.c
--- cipe/crc32.c        2001/02/12 00:25:14     1.3
+++ cipe/crc32.c        2002/10/20 17:17:16
@@ -38,7 +38,9 @@
   /*                                                                        
*/
   /*  --------------------------------------------------------------------  
*/

-static const unsigned long crc32_tab[] = {
+#include "cipe.h"
+
+static const u_int32_t crc32_tab[] = {
       0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
       0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
       0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
@@ -95,9 +97,9 @@

 /* Return a 32-bit CRC of the contents of the buffer. */

-unsigned long crc32(const unsigned char *s, unsigned int len)
+u_int32_t crc32(const unsigned char *s, unsigned int len)
 {
-  unsigned long crc32val = 0;
+  u_int32_t crc32val = 0;
   while (len-- > 0)
     {
       crc32val =
Index: cipe/crcgen.c
===================================================================
RCS file: /home/olaf/common-home/CVSrepos/security/cipe-linux/cipe/crcgen.c,v
retrieving revision 1.4
diff -u -r1.4 crcgen.c
--- cipe/crcgen.c       2002/05/30 11:40:16     1.4
+++ cipe/crcgen.c       2002/10/20 17:19:28
@@ -16,14 +16,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include "cipe.h"

 #define BUFS 4096

-extern unsigned long crc32(const unsigned char *s, unsigned int len);
-
 int main(int argc, char *argv[])
 {
-    unsigned long crc=0UL;
+    u_int32_t crc=0UL;
     if (argc<2)
         exit(1);
     if (argv[1][0]=='-') {
@@ -40,6 +39,6 @@
     } else {
         crc=crc32(argv[1], strlen(argv[1]));
     }
-    printf("#define VERSION_MAGIC 0x%08lXUL\n", crc);
+    printf("#define VERSION_MAGIC 0x%08X\n", crc);
     return 0;
 }

=== end of patch ===





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