| commit | a2abfe00355f6015c4eaaaf52d7689897cecefbe | [log] [tgz] |
|---|---|---|
| author | Thomas Klausner <tk@giga.or.at> | Wed May 27 15:30:28 2015 +0200 |
| committer | Thomas Klausner <tk@giga.or.at> | Wed May 27 15:30:28 2015 +0200 |
| tree | a3b236fe19236444aab206fc53f95f1a531a0bd6 | |
| parent | ef92e112a8bdb04a39569ab616ece6e7358d3d10 [diff] |
Compute in 32-bit integer type and cast result to 16-bit. Found by clang -fsanitize=undefined.
diff --git a/lib/zip_source_pkware.c b/lib/zip_source_pkware.c index ce281ac..ee52fc1 100644 --- a/lib/zip_source_pkware.c +++ b/lib/zip_source_pkware.c
@@ -107,7 +107,7 @@ if (!update_only) { /* decrypt next byte */ tmp = (zip_uint16_t)(ctx->key[2] | 2); - tmp = (zip_uint16_t)((tmp * (tmp ^ 1)) >> 8); + tmp = (zip_uint16_t)(((zip_uint32_t)tmp * (tmp ^ 1)) >> 8); b ^= (Bytef)tmp; }