diff options
| author | Mark Adler <git@madler.net> | 2025-12-21 18:34:14 -0800 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-01-05 15:03:04 -0600 |
| commit | 3509ab515f29002f64455d6e34e19df0c16b1707 (patch) | |
| tree | 5b1ac9ac0ce8e64fc58b3454a721e21d966d32b5 | |
| parent | ba829a458576d1ff0f26fc7230c6de816d1f6a77 (diff) | |
| download | zlib-3509ab515f29002f64455d6e34e19df0c16b1707.tar.gz zlib-3509ab515f29002f64455d6e34e19df0c16b1707.tar.bz2 zlib-3509ab515f29002f64455d6e34e19df0c16b1707.zip | |
Copy only the initialized window contents in inflateCopy.
To avoid the propagation and possible disclosure of uninitialized
memory contents.
| -rw-r--r-- | inflate.c | 7 |
1 files changed, 2 insertions, 5 deletions
| @@ -1446,7 +1446,6 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { | |||
| 1446 | struct inflate_state FAR *state; | 1446 | struct inflate_state FAR *state; |
| 1447 | struct inflate_state FAR *copy; | 1447 | struct inflate_state FAR *copy; |
| 1448 | unsigned char FAR *window; | 1448 | unsigned char FAR *window; |
| 1449 | unsigned wsize; | ||
| 1450 | 1449 | ||
| 1451 | /* check input */ | 1450 | /* check input */ |
| 1452 | if (inflateStateCheck(source) || dest == Z_NULL) | 1451 | if (inflateStateCheck(source) || dest == Z_NULL) |
| @@ -1477,10 +1476,8 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { | |||
| 1477 | copy->distcode = copy->codes + (state->distcode - state->codes); | 1476 | copy->distcode = copy->codes + (state->distcode - state->codes); |
| 1478 | } | 1477 | } |
| 1479 | copy->next = copy->codes + (state->next - state->codes); | 1478 | copy->next = copy->codes + (state->next - state->codes); |
| 1480 | if (window != Z_NULL) { | 1479 | if (window != Z_NULL) |
| 1481 | wsize = 1U << state->wbits; | 1480 | zmemcpy(window, state->window, state->whave); |
| 1482 | zmemcpy(window, state->window, wsize); | ||
| 1483 | } | ||
| 1484 | copy->window = window; | 1481 | copy->window = window; |
| 1485 | dest->state = (struct internal_state FAR *)copy; | 1482 | dest->state = (struct internal_state FAR *)copy; |
| 1486 | return Z_OK; | 1483 | return Z_OK; |
