Skip to content

Commit 6caa36c

Browse files
author
Philip Oakley
committed
zlib.c, packfile.h,config.mak.uname: deflateBound size coercion
The zlib deflateBound() 'size' variable is 32 bits on Windows, but 64 bits on Linux and hence needs careful selection a-priori of NO_DEFLATE_BOUND on Windows. Signed-off-by: Philip Oakley <[email protected]>
1 parent 28ec3d7 commit 6caa36c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

config.mak.uname

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ ifeq ($(uname_S),Windows)
424424
NO_POSIX_GOODIES = UnfortunatelyYes
425425
NATIVE_CRLF = YesPlease
426426
DEFAULT_HELP_FORMAT = html
427+
NO_DEFLATE_BOUND = YesPlease
428+
# the zlib.c deflateBound, compiled for windows, is limited to uLong 32bit sourceLen.
427429

428430
CC = compat/vcbuild/scripts/clink.pl
429431
AR = compat/vcbuild/scripts/lib.pl

zlib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ int git_inflate(git_zstream *strm, int flush)
140140
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
141141
#endif
142142

143+
144+
/*
145+
* The zlib deflateBound() 'size' is uLong. Define NO_DEFLATE_BOUND on
146+
* Windows where uLong is only 32 bits and would result in data loss.
147+
*/
143148
size_t git_deflate_bound(git_zstream *strm, size_t size)
144149
{
145150
return deflateBound(&strm->z, size);

0 commit comments

Comments
 (0)