From owner-freebsd-bugs Thu Sep 19 12:10:05 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id MAA23750 for bugs-outgoing; Thu, 19 Sep 1996 12:10:05 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id MAA23739; Thu, 19 Sep 1996 12:10:03 -0700 (PDT) Resent-Date: Thu, 19 Sep 1996 12:10:03 -0700 (PDT) Resent-Message-Id: <199609191910.MAA23739@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, thorpej@nas.nasa.gov Received: from nostromo.nas.nasa.gov (nostromo.nas.nasa.gov [129.99.223.15]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id MAA19098 for ; Thu, 19 Sep 1996 12:02:19 -0700 (PDT) Received: (from thorpej@localhost) by nostromo.nas.nasa.gov (8.7.5/8.6.9-rAT) id LAA11322; Thu, 19 Sep 1996 11:56:11 -0700 (PDT) Message-Id: <199609191856.LAA11322@nostromo.nas.nasa.gov> Date: Thu, 19 Sep 1996 11:56:11 -0700 (PDT) From: Jason Thorpe Reply-To: thorpej@nas.nasa.gov To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.95 Subject: bin/1648: libmd not 64-bit safe Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 1648 >Category: bin >Synopsis: libmd not 64-bit safe >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 19 12:10:01 PDT 1996 >Last-Modified: >Originator: Jason Thorpe >Organization: Numerical Aerodynamic Simulation Project - NASA Ames >Release: FreeBSD-current 960918, built on NetBSD/alpha >Environment: System: NetBSD nostromo 1.2A NetBSD 1.2A (NOSY) #14: Wed Sep 18 14:54:10 PDT 1996 thorpej@nostromo:/work/clean-current/src/sys/arch/alpha/compile/NOSY alpha >Description: The "md" library is not 64-bit safe. It makes assumptions about the size of shorts and longs. >How-To-Repeat: Build the md library under NetBSD/alpha. It will build fine, but the regression test will fail. >Fix: Diffs below for md4/md5. Note I did not make the necessary modifications to md2; I am not interested in using md2 due to the md2 license. However, the changes to md2 would be quite similar to the changes to md4/md5. ----- snip ----- Index: md4.h =================================================================== RCS file: /mastersrc/netbsd/src/lib/libmd/md4.h,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -c -r1.1.1.1 -r1.3 *** md4.h 1996/09/19 06:32:20 1.1.1.1 --- md4.h 1996/09/19 18:45:42 1.3 *************** *** 24,33 **** --- 24,45 ---- #ifndef _MD4_H_ #define _MD4_H_ + + #include + /* MD4 context. */ typedef struct MD4Context { + #if 0 unsigned long state[4]; /* state (ABCD) */ unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */ + #else + /* + * Within the MD4 library, these are treated as 4-byte quantities, + * and thus _must_ be declared this way. + */ + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + #endif /* 0 */ unsigned char buffer[64]; /* input buffer */ } MD4_CTX; Index: md4c.c =================================================================== RCS file: /mastersrc/netbsd/src/lib/libmd/md4c.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -c -r1.1.1.1 -r1.3 *** md4c.c 1996/09/19 06:32:20 1.1.1.1 --- md4c.c 1996/09/19 18:45:44 1.3 *************** *** 22,33 **** documentation and/or software. */ ! #include "md4.h" #include typedef unsigned char *POINTER; typedef unsigned short int UINT2; typedef unsigned long int UINT4; #define PROTO_LIST(list) list --- 22,40 ---- documentation and/or software. */ ! #include #include + #include "md4.h" + typedef unsigned char *POINTER; + #if 0 typedef unsigned short int UINT2; typedef unsigned long int UINT4; + #else + typedef u_int16_t UINT2; + typedef u_int32_t UINT4; /* MUST be this for 64-bit systems */ + #endif /* 0 */ #define PROTO_LIST(list) list Index: md5.h =================================================================== RCS file: /mastersrc/netbsd/src/lib/libmd/md5.h,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -c -r1.1.1.1 -r1.3 *** md5.h 1996/09/19 06:32:20 1.1.1.1 --- md5.h 1996/09/19 18:45:46 1.3 *************** *** 25,34 **** --- 25,46 ---- #ifndef _MD5_H_ #define _MD5_H_ + + #include + /* MD5 context. */ typedef struct MD5Context { + #if 0 unsigned long state[4]; /* state (ABCD) */ unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */ + #else + /* + * Within the MD5 library, these are treated as 4-byte quantities, + * and thus _must_ be declared this way. + */ + u_int32_t state[4]; /* state (ABCD) */ + u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + #endif /* 0 */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; Index: md5c.c =================================================================== RCS file: /mastersrc/netbsd/src/lib/libmd/md5c.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -c -r1.1.1.1 -r1.3 *** md5c.c 1996/09/19 06:32:19 1.1.1.1 --- md5c.c 1996/09/19 18:45:47 1.3 *************** *** 23,34 **** documentation and/or software. */ ! #include "md5.h" #include typedef unsigned char *POINTER; typedef unsigned short int UINT2; typedef unsigned long int UINT4; #define PROTO_LIST(list) list --- 23,41 ---- documentation and/or software. */ ! #include #include + #include "md5.h" + typedef unsigned char *POINTER; + #if 0 typedef unsigned short int UINT2; typedef unsigned long int UINT4; + #else + typedef u_int16_t UINT2; + typedef u_int32_t UINT4; /* MUST be this for 64-bit systems */ + #endif /* 0 */ #define PROTO_LIST(list) list >Audit-Trail: >Unformatted: