[zlib] fixed warning C4244: conversion, possible loss of data

This commit is contained in:
unknown 2015-05-24 14:54:56 -04:00
parent 63d5805aa2
commit 8f2e0e066d
2 changed files with 12 additions and 11 deletions

View File

@ -32,14 +32,14 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys)
static Byte decrypt_byte(unsigned long* pkeys)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
return (Byte)(((temp * (temp ^ 1)) >> 8) & 0xFF);
}
/***********************************************************************
@ -95,8 +95,8 @@ static int crypthead(const char* passwd, /* password string */
unsigned long crcForCrypting)
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
Byte t; /* temporary */
Byte c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
@ -114,17 +114,17 @@ static int crypthead(const char* passwd, /* password string */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
c = (Byte)((rand() >> 7) & 0xFF);
header[n] = zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
buf[n] = zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (crcForCrypting >> 16) & 0xFF, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (crcForCrypting >> 24) & 0xFF, t);
return n;
}

View File

@ -1368,8 +1368,9 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
{
#ifndef NOCRYPT
uInt i;
int t;
for (i=0;i<zi->ci.pos_in_buffered_data;i++)
Byte t;
for (i = 0; i < zi->ci.pos_in_buffered_data; i++)
zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t);
#endif
}