Commit df015676 authored by deuce's avatar deuce
Browse files

More 64-bit fixups.

parent 53a88c2c
......@@ -79,22 +79,22 @@ void MD5CALL MD5_open(MD5 *md5)
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) += F((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) += G((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) += H((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) += I((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
......@@ -102,9 +102,9 @@ void MD5CALL MD5_open(MD5 *md5)
/* MD5 basic transformation. Transforms state based on block. */
static void MD5Transform(UINT4 state[4], const BYTE block[64])
static void MD5Transform(uint32_t state[4], const BYTE block[64])
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[MD5_DIGEST_SIZE];
uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[MD5_DIGEST_SIZE];
/* Move contents of block to x, putting bytes in little-endian order. */
#ifdef LITTLE_ENDIAN
memcpy(x, block, 64);
......@@ -113,8 +113,8 @@ static void MD5Transform(UINT4 state[4], const BYTE block[64])
unsigned int i, j;
for (i = j = 0; i < MD5_DIGEST_SIZE; i++, j+= 4)
{
x[i] = (UINT4) block[j] | (UINT4) block[j+1] << 8 |
(UINT4) block[j+2] << 16 | (UINT4) block[j+3] << 24;
x[i] = (uint32_t) block[j] | (uint32_t) block[j+1] << 8 |
(uint32_t) block[j+2] << 16 | (uint32_t) block[j+3] << 24;
}
}
#endif
......@@ -200,9 +200,9 @@ void MD5CALL MD5_digest(MD5 *md5, const void *input, size_t inputLen)
/* Compute number of bytes mod 64 */
index = (unsigned int)((md5->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((md5->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3))
if ((md5->count[0] += ((uint32_t)inputLen << 3)) < ((uint32_t)inputLen << 3))
md5->count[1]++;
md5->count[1] += ((UINT4)inputLen >> 29);
md5->count[1] += ((uint32_t)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.*/
if (inputLen >= partLen)
......@@ -224,7 +224,7 @@ void MD5CALL MD5_digest(MD5 *md5, const void *input, size_t inputLen)
*/
#ifdef LITTLE_ENDIAN
#define ENCODE(p,n) *(UINT4 *)(p) = n
#define ENCODE(p,n) *(uint32_t *)(p) = n
#else
#define ENCODE(p,n) (p)[0]=n,(p)[1]=n>>8,(p)[2]=n>>16,(p)[3]=n>>24
#endif
......
......@@ -33,20 +33,18 @@ documentation and/or software.
#define H__MD5
#include <stddef.h> /* size_t */
#include <gen_defs.h> /* uint32_t */
#define MD5_DIGEST_SIZE 16
#ifndef UINT4
typedef unsigned long UINT4;
#endif
#ifndef BYTE
typedef unsigned char BYTE;
#endif
typedef struct
{
UINT4 state[4];
UINT4 count[2];
uint32_t state[4];
uint32_t count[2];
BYTE buffer[64];
} MD5;
......
......@@ -771,10 +771,10 @@ static void set_convenience_ptr(smbmsg_t* msg, ushort hfield_type, void* hfield_
msg->expiration=*(time_t*)hfield_dat;
break;
case SMB_PRIORITY:
msg->priority=*(ulong*)hfield_dat;
msg->priority=*(uint32_t*)hfield_dat;
break;
case SMB_COST:
msg->cost=*(ulong*)hfield_dat;
msg->cost=*(uint32_t*)hfield_dat;
break;
case RFC822MSGID:
msg->id=(char*)hfield_dat;
......@@ -1275,7 +1275,8 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
int wr;
long length;
long newlen;
ulong l,*buf;
ulong l;
uint32_t *buf;
time_t start=0;
if(!smb->status.max_crcs)
......@@ -1304,7 +1305,7 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
}
length=filelength(file);
if(length<0L || length%sizeof(long)) {
if(length<0L || length%sizeof(uint32_t)) {
close(file);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"invalid file length: %ld", length);
......@@ -1312,7 +1313,7 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
}
if(length!=0) {
if((buf=(ulong*)malloc(length))==NULL) {
if((buf=(uint32_t*)malloc(length))==NULL) {
close(file);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"malloc failure of %ld bytes"
......@@ -1329,10 +1330,10 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
return(SMB_ERR_READ);
}
for(l=0;l<length/sizeof(long);l++)
for(l=0;l<length/sizeof(int32_t);l++)
if(crc==buf[l])
break;
if(l<length/sizeof(long)) { /* Dupe CRC found */
if(l<length/sizeof(int32_t)) { /* Dupe CRC found */
close(file);
free(buf);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
......@@ -1340,8 +1341,8 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
return(SMB_DUPE_MSG);
}
if(length>=(long)(smb->status.max_crcs*sizeof(long))) {
newlen=(smb->status.max_crcs-1)*sizeof(long);
if(length>=(long)(smb->status.max_crcs*sizeof(int32_t))) {
newlen=(smb->status.max_crcs-1)*sizeof(int32_t);
chsize(file,0); /* truncate it */
lseek(file,0L,SEEK_SET);
write(file,buf+(length-newlen),newlen);
......
......@@ -116,7 +116,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
return(buf);
}
smb_fread(smb,lzhbuf,length,smb->sdt_fp);
lzhlen=*(long*)lzhbuf;
lzhlen=*(int32_t*)lzhbuf;
if((p=(char*)realloc(buf,l+lzhlen+3L))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for text buffer"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment