[zlib] fixed warning C4244: conversion, possible loss of data
This commit is contained in:
parent
63d5805aa2
commit
8f2e0e066d
|
@ -32,14 +32,14 @@
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Return the next byte in the pseudo-random sequence
|
* 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
|
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||||
* unpredictable manner on 16-bit systems; not a problem
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
* with any known compiler so far, though */
|
* with any known compiler so far, though */
|
||||||
|
|
||||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
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)
|
unsigned long crcForCrypting)
|
||||||
{
|
{
|
||||||
int n; /* index in random header */
|
int n; /* index in random header */
|
||||||
int t; /* temporary */
|
Byte t; /* temporary */
|
||||||
int c; /* random byte */
|
Byte c; /* random byte */
|
||||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||||
static unsigned calls = 0; /* ensure different random header each time */
|
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);
|
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||||
{
|
{
|
||||||
c = (rand() >> 7) & 0xff;
|
c = (Byte)((rand() >> 7) & 0xFF);
|
||||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
header[n] = zencode(pkeys, pcrc_32_tab, c, t);
|
||||||
}
|
}
|
||||||
/* Encrypt random header (last two bytes is high word of crc) */
|
/* Encrypt random header (last two bytes is high word of crc) */
|
||||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
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++] = zencode(pkeys, pcrc_32_tab, (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 >> 24) & 0xFF, t);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1368,8 +1368,9 @@ local int zip64FlushWriteBuffer(zip64_internal* zi)
|
||||||
{
|
{
|
||||||
#ifndef NOCRYPT
|
#ifndef NOCRYPT
|
||||||
uInt i;
|
uInt i;
|
||||||
int t;
|
Byte t;
|
||||||
for (i=0;i<zi->ci.pos_in_buffered_data;i++)
|
|
||||||
|
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);
|
zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue