diff --git a/CMakeLists.txt b/CMakeLists.txt index 40494872c4..80de8c7d9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -548,21 +548,21 @@ if(${bytecodeRuntime} STREQUAL "llvm") endif() endif() +if(APPLE) + find_library(APPLE_CORE_FOUNDATION CoreFoundation) + if (NOT APPLE_CORE_FOUNDATION) + message(FATAL_ERROR "Apple CoreFoundation framework not found") + endif() + find_library(APPLE_SECURITY Security) + if (NOT APPLE_SECURITY) + message(FATAL_ERROR "Apple Security framework not found") + endif() +endif() + # libfreshclam & application dependencies if(NOT ENABLE_LIBCLAMAV_ONLY) find_package(CURL REQUIRED) - if(APPLE) - find_library(APPLE_CORE_FOUNDATION CoreFoundation) - if (NOT APPLE_CORE_FOUNDATION) - message(FATAL_ERROR "Apple CoreFoundation framework not found") - endif() - find_library(APPLE_SECURITY Security) - if (NOT APPLE_SECURITY) - message(FATAL_ERROR "Apple Security framework not found") - endif() - endif() - if(ENABLE_APP) find_package(CURSES REQUIRED) diff --git a/Cargo.lock b/Cargo.lock index ceb99f0865..6bbe5b8852 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -25,9 +40,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bindgen" @@ -48,7 +63,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.41", + "syn 2.0.52", "which", ] @@ -66,9 +81,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -79,11 +94,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bumpalo" +version = "3.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" + [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -115,6 +136,12 @@ dependencies = [ "toml", ] +[[package]] +name = "cc" +version = "1.0.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" + [[package]] name = "cexpr" version = "0.6.0" @@ -130,6 +157,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.4", +] + [[package]] name = "clamav_rust" version = "0.0.1" @@ -137,6 +178,7 @@ dependencies = [ "base64", "bindgen", "cbindgen", + "delharc", "flate2", "hex", "hex-literal", @@ -156,9 +198,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", "libc", @@ -171,55 +213,54 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-deque" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.16" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" @@ -237,6 +278,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "delharc" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f420b1ede12094758715adaee221d93cb2af86dc499cef368ef81a23fea96029" +dependencies = [ + "bitflags 2.4.2", + "chrono", + "memchr", +] + [[package]] name = "digest" version = "0.10.7" @@ -249,9 +301,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encoding_rs" @@ -285,9 +337,9 @@ dependencies = [ [[package]] name = "exr" -version = "1.71.0" +version = "1.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" dependencies = [ "bit_field", "flume", @@ -307,9 +359,9 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fdeflate" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" dependencies = [ "simd-adler32", ] @@ -345,9 +397,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" dependencies = [ "color_quant", "weezl", @@ -361,10 +413,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "2.2.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ + "cfg-if", "crunchy", ] @@ -394,18 +447,41 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", ] [[package]] name = "image" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -413,7 +489,6 @@ dependencies = [ "exr", "gif", "jpeg-decoder", - "num-rational", "num-traits", "png", "qoi", @@ -447,13 +522,22 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jpeg-decoder" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" dependencies = [ "rayon", ] +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -474,25 +558,25 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -506,24 +590,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "minimal-lexical" @@ -533,9 +608,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -553,39 +628,27 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -626,9 +689,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "png" -version = "0.17.10" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -639,12 +702,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.41", + "syn 2.0.52", ] [[package]] @@ -658,9 +721,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -676,18 +739,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -695,28 +758,19 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -726,9 +780,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -758,9 +812,9 @@ dependencies = [ [[package]] name = "rustfft" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d4f6cbdb180c9f4b2a26bbf01c4e647f1e1dea22fe8eb9db54198b32f9434" +checksum = "43806561bc506d0c5d160643ad742e3161049ac01027b5e6d7524091fd401d86" dependencies = [ "num-complex", "num-integer", @@ -773,11 +827,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -786,9 +840,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "scopeguard" @@ -798,29 +852,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -863,9 +917,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "spin" @@ -895,9 +949,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -906,42 +960,41 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.1" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.52", ] [[package]] name = "tiff" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" dependencies = [ "flate2", "jpeg-decoder", @@ -959,9 +1012,9 @@ dependencies = [ [[package]] name = "transpose" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6522d49d03727ffb138ae4cbc1283d3774f0d10aa7f9bf52e6784c45daf9b23" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" dependencies = [ "num-integer", "strength_reduce", @@ -981,15 +1034,15 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "uuid" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" [[package]] name = "version_check" @@ -997,11 +1050,65 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wasm-bindgen" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.52", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "which" @@ -1022,27 +1129,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets 0.52.4", ] -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" @@ -1058,7 +1152,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -1078,17 +1172,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -1099,9 +1193,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -1111,9 +1205,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -1123,9 +1217,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -1135,9 +1229,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -1147,9 +1241,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -1159,9 +1253,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -1171,9 +1265,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "zune-inflate" diff --git a/clamd/tcpserver.c b/clamd/tcpserver.c index 92ce15ab9c..f7784ba698 100644 --- a/clamd/tcpserver.c +++ b/clamd/tcpserver.c @@ -56,7 +56,8 @@ int tcpserver(int **lsockets, unsigned int *nlsockets, char *ipaddr, const struc int *sockets; int sockfd = 0, backlog; int *t; - char *estr, port[10]; + const char *estr = NULL; + char port[10]; int yes = 1; int res; unsigned int i = 0; diff --git a/clamd/thrmgr.c b/clamd/thrmgr.c index d798ca20ee..4df6af90b0 100644 --- a/clamd/thrmgr.c +++ b/clamd/thrmgr.c @@ -267,7 +267,7 @@ int thrmgr_printstats(int f, char term) const struct cl_engine **s; /* new engine */ ++seen_cnt; - s = realloc(seen, seen_cnt * sizeof(*seen)); + s = realloc((void *)seen, seen_cnt * sizeof(*seen)); if (!s) { error_flag = 1; break; @@ -285,7 +285,7 @@ int thrmgr_printstats(int f, char term) } mdprintf(f, "\n"); } - free(seen); + free((void *)seen); #ifdef HAVE_MALLINFO { struct mallinfo inf = mallinfo(); diff --git a/clamdtop/clamdtop.c b/clamdtop/clamdtop.c index 181f987aff..b4dca64d3c 100644 --- a/clamdtop/clamdtop.c +++ b/clamdtop/clamdtop.c @@ -183,7 +183,7 @@ static WINDOW *stats_window = NULL; static WINDOW *status_bar_window = NULL; static WINDOW *mem_window = NULL; -static const char *status_bar_keys[10]; +static char *status_bar_keys[10]; static unsigned maxy = 0, maxx = 0; static char *queue_header = NULL; static char *multi_queue_header = NULL; diff --git a/common/scanmem.c b/common/scanmem.c index a0b4d4b5c2..a211d8e223 100644 --- a/common/scanmem.c +++ b/common/scanmem.c @@ -227,47 +227,47 @@ int walkmodules_th(proc_callback callback, void *data, struct mem_info *info) } /* Check and transform non ANSI filenames to ANSI using altnames */ - if (GetModuleFileNameEx) { - HANDLE hFile = CreateFile( - me32.szExePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); - - if (hFile == INVALID_HANDLE_VALUE) { - DWORD err = GetLastError(); - wchar_t name[MAX_PATH + 1]; - char *converted = NULL; - HANDLE p; - - if (err == ERROR_BAD_NETPATH) { - logg(LOGG_WARNING, "Warning scanning files on non-ansi network paths is not " - "supported\n"); - logg(LOGG_WARNING, "File: %s\n", me32.szExePath); - continue; - } - - if ((err != ERROR_INVALID_NAME) && (err != ERROR_PATH_NOT_FOUND)) { - logg(LOGG_WARNING, "Expected ERROR_INVALID_NAME/ERROR_PATH_NOT_FOUND but got %d\n", - err); - continue; - } - - p = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, - ps.th32ProcessID); - if (!GetModuleFileNameEx(p, NULL, name, MAX_PATH)) { - logg(LOGG_WARNING, "GetModuleFileNameExW() failed %d\n", GetLastError()); - CloseHandle(p); - continue; - } + HANDLE hFile = CreateFileA( + me32.szExePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); + + if (hFile == INVALID_HANDLE_VALUE) { + DWORD err = GetLastError(); + wchar_t nameW[MAX_PATH + 1]; + char *converted = NULL; + HANDLE p; + + if (err == ERROR_BAD_NETPATH) { + logg(LOGG_WARNING, "Warning scanning files on non-ansi network paths is not " + "supported\n"); + logg(LOGG_WARNING, "File: %s\n", me32.szExePath); + continue; + } + + if ((err != ERROR_INVALID_NAME) && (err != ERROR_PATH_NOT_FOUND)) { + logg(LOGG_WARNING, "Expected ERROR_INVALID_NAME/ERROR_PATH_NOT_FOUND but got %d\n", + err); + continue; + } + + p = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, + ps.th32ProcessID); + + if (!GetModuleFileNameExW(p, NULL, nameW, MAX_PATH)) { + logg(LOGG_WARNING, "GetModuleFileNameExW() failed %d\n", GetLastError()); CloseHandle(p); + continue; + } + CloseHandle(p); - if (!(converted = getaltpath(name))) { - logg(LOGG_WARNING, "Cannot map filename to ANSI codepage\n"); - continue; - } - strcpy(me32.szExePath, converted); - free(converted); - } else - CloseHandle(hFile); + if (!(converted = getaltpath(nameW))) { + logg(LOGG_WARNING, "Cannot map filename to ANSI codepage\n"); + continue; + } + strcpy(me32.szExePath, converted); + free(converted); + } else { + CloseHandle(hFile); } do @@ -319,8 +319,8 @@ int walkmodules_psapi(proc_callback callback, void *data, struct mem_info *info) continue; } - if (!GetModuleBaseName(hProc, mods[0], ps.szExeFile, - MAX_PATH - 1)) { + if (!GetModuleBaseNameA(hProc, mods[0], ps.szExeFile, + MAX_PATH - 1)) { CloseHandle(hProc); continue; } @@ -515,8 +515,8 @@ int dump_pe(const char *filename, PROCESSENTRY32 ProcStruct, /* PE Realignment */ align_pe(buffer, me32.modBaseSize); - hFile = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { logg(LOGG_INFO, "Error creating %s\n", filename); free(buffer); @@ -598,7 +598,7 @@ int scanmem_cb(PROCESSENTRY32 ProcStruct, MODULEENTRY32 me32, void *data, struct snprintf(expandmodule, MAX_PATH - 1, "%%SystemRoot%%\\%s", &me32.szExePath[12]); expandmodule[MAX_PATH - 1] = 0; - ExpandEnvironmentStrings(expandmodule, modulename, MAX_PATH - 1); + ExpandEnvironmentStringsA(expandmodule, modulename, MAX_PATH - 1); modulename[MAX_PATH - 1] = 0; } @@ -630,7 +630,7 @@ int scanmem_cb(PROCESSENTRY32 ProcStruct, MODULEENTRY32 me32, void *data, struct if ((fd = dump_pe(dumped, ProcStruct, me32)) > 0) { close(fd); scan_data->res = scanfile(dumped, scan_data, info); - DeleteFile(dumped); + DeleteFileA(dumped); } free(dumped); } @@ -667,8 +667,8 @@ int scanmem(struct mem_info *info) data.processes = 0; data.modules = 0; - HMODULE psapi_ok = LoadLibrary("psapi.dll"); - HMODULE k32_ok = LoadLibrary("kernel32.dll"); + HMODULE psapi_ok = LoadLibraryA("psapi.dll"); + HMODULE k32_ok = LoadLibraryA("kernel32.dll"); if (!(psapi_ok || k32_ok)) { logg(LOGG_INFO, " *** Memory Scanning is not supported on this OS ***\n\n"); diff --git a/common/win/cert_util_win.c b/common/win/cert_util_win.c index 022d5b7907..dbc7e9886e 100644 --- a/common/win/cert_util_win.c +++ b/common/win/cert_util_win.c @@ -49,7 +49,7 @@ cl_error_t cert_store_load(X509 **trusted_certs, size_t trusted_cert_count) cert_store_t *store = NULL; bool locked = false; - hStore = CertOpenSystemStoreA(NULL, "ROOT"); + hStore = CertOpenSystemStoreA(0, "ROOT"); if (NULL == hStore) { mprintf(LOGG_ERROR, "Failed to open system certificate store.\n"); goto done; diff --git a/libclamav/7z_iface.c b/libclamav/7z_iface.c index f3dbb1627a..0ccf13c149 100644 --- a/libclamav/7z_iface.c +++ b/libclamav/7z_iface.c @@ -171,7 +171,7 @@ int cli_7unz(cli_ctx *ctx, size_t offset) } } } - if (CL_VIRUS == cli_matchmeta(ctx, name, 0, f->Size, encrypted, i, f->CrcDefined ? f->Crc : 0, NULL)) { + if (CL_VIRUS == cli_matchmeta(ctx, name, 0, f->Size, encrypted, i, f->CrcDefined ? f->Crc : 0)) { found = CL_VIRUS; break; } diff --git a/libclamav/CMakeLists.txt b/libclamav/CMakeLists.txt index 9b3aed89eb..d20bf71f5b 100644 --- a/libclamav/CMakeLists.txt +++ b/libclamav/CMakeLists.txt @@ -450,6 +450,13 @@ if(ENABLE_SHARED_LIB) ${CMAKE_DL_LIBS} m ) endif() + + if(APPLE) + target_link_libraries( clamav + PUBLIC + ${APPLE_CORE_FOUNDATION} ) + endif() + set_target_properties( clamav PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}" VERSION ${LIBCLAMAV_VERSION} SOVERSION ${LIBCLAMAV_SOVERSION} ) @@ -549,6 +556,7 @@ if(ENABLE_STATIC_LIB) if (ENABLE_UNRAR) target_link_libraries( clamav_static PUBLIC ClamAV::libunrar_iface_static ClamAV::libunrar_iface_iface) endif() + if (WIN32) target_link_libraries( clamav_static PUBLIC @@ -563,6 +571,13 @@ if(ENABLE_STATIC_LIB) ${CMAKE_DL_LIBS} m ) endif() + + if(APPLE) + target_link_libraries( clamav_static + PUBLIC + ${APPLE_CORE_FOUNDATION} ) + endif() + set_target_properties( clamav_static PROPERTIES ARCHIVE_OUTPUT_NAME clamav_static COMPILE_FLAGS "${WARNCFLAGS}" diff --git a/libclamav/blob.c b/libclamav/blob.c index fc7b1e9489..978931ef9b 100644 --- a/libclamav/blob.c +++ b/libclamav/blob.c @@ -654,7 +654,7 @@ cl_error_t fileblobScan(const fileblob *fb) lseek(fb->fd, 0, SEEK_SET); FSTAT(fb->fd, &sb); - rc = cli_matchmeta(fb->ctx, fb->b.name, sb.st_size, sb.st_size, 0, 0, 0, NULL); + rc = cli_matchmeta(fb->ctx, fb->b.name, sb.st_size, sb.st_size, 0, 0, 0); if (rc != CL_SUCCESS) { return rc; } diff --git a/libclamav/cpio.c b/libclamav/cpio.c index e1cd9d86ca..9dceafb415 100644 --- a/libclamav/cpio.c +++ b/libclamav/cpio.c @@ -159,7 +159,7 @@ cl_error_t cli_scancpio_old(cli_ctx *ctx) if (!filesize) continue; - status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL); + status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0); if (status != CL_SUCCESS) { goto done; } @@ -249,7 +249,7 @@ cl_error_t cli_scancpio_odc(cli_ctx *ctx) continue; } - status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL); + status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0); if (status == CL_VIRUS) { goto done; } @@ -338,7 +338,7 @@ cl_error_t cli_scancpio_newc(cli_ctx *ctx, int crc) continue; } - status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0, NULL); + status = cli_matchmeta(ctx, name, filesize, filesize, 0, file, 0); if (status == CL_VIRUS) { goto done; } diff --git a/libclamav/dconf.c b/libclamav/dconf.c index 067a5d2c54..fb87c453b4 100644 --- a/libclamav/dconf.c +++ b/libclamav/dconf.c @@ -107,6 +107,7 @@ static struct dconf_module modules[] = { {"ARCHIVE", "APM", ARCH_CONF_APM, 1}, {"ARCHIVE", "EGG", ARCH_CONF_EGG, 1}, {"ARCHIVE", "UDF", ARCH_CONF_UDF, 1}, + {"ARCHIVE", "LHA", ARCH_CONF_LHA_LZH, 1}, {"DOCUMENT", "HTML", DOC_CONF_HTML, 1}, {"DOCUMENT", "RTF", DOC_CONF_RTF, 1}, diff --git a/libclamav/dconf.h b/libclamav/dconf.h index 0e96b33e64..e5df428e49 100644 --- a/libclamav/dconf.h +++ b/libclamav/dconf.h @@ -97,6 +97,7 @@ struct cli_dconf { #define ARCH_CONF_APM 0x2000000 #define ARCH_CONF_EGG 0x4000000 #define ARCH_CONF_UDF 0x8000000 +#define ARCH_CONF_LHA_LZH 0x10000000 /* Document flags */ #define DOC_CONF_HTML 0x1 diff --git a/libclamav/dmg.c b/libclamav/dmg.c index 61696c2024..e7fde7ef22 100644 --- a/libclamav/dmg.c +++ b/libclamav/dmg.c @@ -924,7 +924,7 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish break; } - ret = cli_checklimits("dmg_stripe_bzip", ctx, (unsigned long)(size_so_far + sizeof(obuf)), 0, 0); + ret = cli_checklimits("dmg_stripe_bzip", ctx, size_so_far + sizeof(obuf), 0, 0); if (ret != CL_CLEAN) { break; } @@ -953,7 +953,7 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish size_so_far += next_write; dmg_bzipmsg("dmg_stripe_bzip: size_so_far: " STDu64 " next_write: %zu\n", size_so_far, next_write); - ret = cli_checklimits("dmg_stripe_bzip", ctx, (unsigned long)(size_so_far + sizeof(obuf)), 0, 0); + ret = cli_checklimits("dmg_stripe_bzip", ctx, size_so_far + sizeof(obuf), 0, 0); if (ret != CL_CLEAN) { break; } diff --git a/libclamav/filetypes.c b/libclamav/filetypes.c index 8cd4dcb1f2..284120a0e8 100644 --- a/libclamav/filetypes.c +++ b/libclamav/filetypes.c @@ -140,6 +140,7 @@ static const struct ftmap_s { { "CL_TYPE_UDF", CL_TYPE_UDF }, { "CL_TYPE_ONENOTE", CL_TYPE_ONENOTE }, { "CL_TYPE_PYTHON_COMPILED", CL_TYPE_PYTHON_COMPILED }, + { "CL_TYPE_LHA_LZH", CL_TYPE_LHA_LZH }, { NULL, CL_TYPE_IGNORED } }; // clang-format on diff --git a/libclamav/filetypes.h b/libclamav/filetypes.h index 9a553d92ce..637b7487a3 100644 --- a/libclamav/filetypes.h +++ b/libclamav/filetypes.h @@ -94,6 +94,7 @@ typedef enum cli_file { CL_TYPE_EGG, CL_TYPE_ONENOTE, CL_TYPE_PYTHON_COMPILED, + CL_TYPE_LHA_LZH, /* Section for partition types */ CL_TYPE_PART_ANY, /* unknown partition type */ diff --git a/libclamav/filetypes_int.h b/libclamav/filetypes_int.h index 0edbd04339..832b6c3942 100644 --- a/libclamav/filetypes_int.h +++ b/libclamav/filetypes_int.h @@ -298,5 +298,8 @@ static const char *ftypes_int[] = { "0:0:00010d0a:PyPy 3.8 byte-compiled (.pyc):CL_TYPE_ANY:CL_TYPE_PYTHON_COMPILED:200", "0:0:50010d0a:PyPy 3.9 byte-compiled (.pyc):CL_TYPE_ANY:CL_TYPE_PYTHON_COMPILED:200", "1:0:??0d0d0a:Python 3.7 or newer byte-compiled (.pyc):CL_TYPE_ANY:CL_TYPE_PYTHON_COMPILED:200", + "1:2:2d6c68(30|31|32|33|34|35|36|37|64|78)2d:LHA or LZH archive:CL_TYPE_ANY:CL_TYPE_LHA_LZH:210", + "1:2:2d6c7a(73|34|35)2d:LHA archive using .LZS extension:CL_TYPE_ANY:CL_TYPE_LHA_LZH:210", + "1:2:2d706d302d:LHA archive using PMarc (.PMA) extension:CL_TYPE_ANY:CL_TYPE_LHA_LZH:210", NULL}; #endif diff --git a/libclamav/hfsplus.c b/libclamav/hfsplus.c index d9b510c1b8..034dcbf74e 100644 --- a/libclamav/hfsplus.c +++ b/libclamav/hfsplus.c @@ -344,7 +344,7 @@ static cl_error_t hfsplus_scanfile(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, goto done; } #endif - status = cli_checklimits("hfsplus_scanfile", ctx, (unsigned long)targetSize, 0, 0); + status = cli_checklimits("hfsplus_scanfile", ctx, targetSize, 0, 0); if (status != CL_SUCCESS) { goto done; } diff --git a/libclamav/ishield.c b/libclamav/ishield.c index 3ea28e3d5e..53035c6398 100644 --- a/libclamav/ishield.c +++ b/libclamav/ishield.c @@ -406,7 +406,7 @@ cl_error_t cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) (size_t)(data - fname) >= sz - fsize) break; cli_dbgmsg("ishield: @%lx found file %s (%s) - version %s - size %lu\n", (unsigned long int)coff, fname, path, version, (unsigned long int)fsize); - if (CL_SUCCESS != cli_matchmeta(ctx, fname, fsize, fsize, 0, fc++, 0, NULL)) { + if (CL_SUCCESS != cli_matchmeta(ctx, fname, fsize, fsize, 0, fc++, 0)) { ret = CL_VIRUS; break; } diff --git a/libclamav/iso9660.c b/libclamav/iso9660.c index f9833b79a8..1e77e5dc40 100644 --- a/libclamav/iso9660.c +++ b/libclamav/iso9660.c @@ -191,7 +191,7 @@ static cl_error_t iso_parse_dir(iso9660_t *iso, unsigned int block, unsigned int filesz = cli_readint32(dir + 10); cli_dbgmsg("iso_parse_dir: %s '%s': off %x - size %x - flags %x - unit size %x - gap size %x - volume %u\n", (dir[25] & 2) ? "Directory" : "File", iso->buf, fileoff, filesz, dir[25], dir[26], dir[27], cli_readint32(&dir[28]) & 0xffff); - ret = cli_matchmeta(ctx, iso->buf, filesz, filesz, 0, 0, 0, NULL); + ret = cli_matchmeta(ctx, iso->buf, filesz, filesz, 0, 0, 0); if (ret != CL_SUCCESS) { break; } diff --git a/libclamav/jsparse/js-norm.c b/libclamav/jsparse/js-norm.c index 2a6d8354d3..a958028385 100644 --- a/libclamav/jsparse/js-norm.c +++ b/libclamav/jsparse/js-norm.c @@ -623,7 +623,7 @@ static void decode_de(yystype *params[], struct text_buffer *txtbuf) else textbuffer_append(txtbuf, tokens[val]); } while (*p); - free(tokens); + free((void *)tokens); textbuffer_append(txtbuf, "\0"); } diff --git a/libclamav/libclamav.map b/libclamav/libclamav.map index 9433a8c0ec..457679721e 100644 --- a/libclamav/libclamav.map +++ b/libclamav/libclamav.map @@ -301,6 +301,8 @@ CLAMAV_PRIVATE { fuzzy_hash_calculate_image; ffierror_fmt; cli_magic_scan_buff; + cli_checklimits; + cli_matchmeta; __cli_strcasestr; __cli_strndup; diff --git a/libclamav/libmspack.c b/libclamav/libmspack.c index b74951dfc4..8773316d06 100644 --- a/libclamav/libmspack.c +++ b/libclamav/libmspack.c @@ -383,7 +383,7 @@ cl_error_t cli_scanmscab(cli_ctx *ctx, off_t sfx_offset) uint64_t max_size; ret = cli_matchmeta(ctx, cab_f->filename, 0, cab_f->length, 0, - files, 0, NULL); + files, 0); if (CL_SUCCESS != ret) { goto done; } @@ -512,7 +512,7 @@ cl_error_t cli_scanmschm(cli_ctx *ctx) uint64_t max_size; ret = cli_matchmeta(ctx, mschm_f->filename, 0, mschm_f->length, - 0, files, 0, NULL); + 0, files, 0); if (CL_SUCCESS != ret) { goto done; } diff --git a/libclamav/matcher-hash.c b/libclamav/matcher-hash.c index 809746f02b..75c1e72902 100644 --- a/libclamav/matcher-hash.c +++ b/libclamav/matcher-hash.c @@ -116,12 +116,12 @@ int hm_addhash_bin(struct cli_matcher *root, const void *binhash, cli_hash_type_ if (!szh->hash_array) { cli_errmsg("hm_addhash_bin: failed to grow hash array to %u entries\n", szh->items); szh->items = 0; - MPOOL_FREE(root->mempool, szh->virusnames); + MPOOL_FREE(root->mempool, (void *)szh->virusnames); szh->virusnames = NULL; return CL_EMEM; } - szh->virusnames = MPOOL_REALLOC2(root->mempool, szh->virusnames, sizeof(*szh->virusnames) * szh->items); + szh->virusnames = MPOOL_REALLOC2(root->mempool, (void *)szh->virusnames, sizeof(*szh->virusnames) * szh->items); if (!szh->virusnames) { cli_errmsg("hm_addhash_bin: failed to grow virusname array to %u entries\n", szh->items); szh->items = 0; @@ -319,7 +319,7 @@ void hm_free(struct cli_matcher *root) MPOOL_FREE(root->mempool, szh->hash_array); while (szh->items) MPOOL_FREE(root->mempool, (void *)szh->virusnames[--szh->items]); - MPOOL_FREE(root->mempool, szh->virusnames); + MPOOL_FREE(root->mempool, (void *)szh->virusnames); MPOOL_FREE(root->mempool, szh); } CLI_HTU32_FREE(ht, root->mempool); @@ -334,6 +334,6 @@ void hm_free(struct cli_matcher *root) MPOOL_FREE(root->mempool, szh->hash_array); while (szh->items) MPOOL_FREE(root->mempool, (void *)szh->virusnames[--szh->items]); - MPOOL_FREE(root->mempool, szh->virusnames); + MPOOL_FREE(root->mempool, (void *)szh->virusnames); } } diff --git a/libclamav/matcher.c b/libclamav/matcher.c index 06b4568154..986be4facd 100644 --- a/libclamav/matcher.c +++ b/libclamav/matcher.c @@ -1469,14 +1469,14 @@ cl_error_t cli_scan_fmap(cli_ctx *ctx, cli_file_t ftype, bool filetype_only, str continue; \ } -cl_error_t cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1, void *res2) +cl_error_t cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1) { const struct cli_cdb *cdb; cl_error_t ret = CL_SUCCESS; - cli_dbgmsg("CDBNAME:%s:%llu:%s:%llu:%llu:%d:%u:%u:%p\n", + cli_dbgmsg("CDBNAME:%s:%llu:%s:%llu:%llu:%d:%u:%u\n", cli_ftname(cli_recursion_stack_get_type(ctx, -1)), (long long unsigned)fsizec, fname, (long long unsigned)fsizec, (long long unsigned)fsizer, - encrypted, filepos, res1, res2); + encrypted, filepos, res1); if (ctx->engine && ctx->engine->cb_meta) { if (ctx->engine->cb_meta(cli_ftname(cli_recursion_stack_get_type(ctx, -1)), fsizec, fname, fsizer, encrypted, filepos, ctx->cb_ctx) == CL_VIRUS) { diff --git a/libclamav/matcher.h b/libclamav/matcher.h index a6830cc96a..ed2508eb87 100644 --- a/libclamav/matcher.h +++ b/libclamav/matcher.h @@ -375,7 +375,7 @@ cl_error_t cli_caloff(const char *offstr, const struct cli_target_info *info, un */ cl_error_t cli_check_fp(cli_ctx *ctx, const char *vname); -cl_error_t cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1, void *res2); +cl_error_t cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1); /** Parse the executable headers and, if successful, populate exeinfo * diff --git a/libclamav/ole2_extract.c b/libclamav/ole2_extract.c index 38af43a541..238ff7a689 100644 --- a/libclamav/ole2_extract.c +++ b/libclamav/ole2_extract.c @@ -247,8 +247,14 @@ int ole2_list_delete(ole2_list_t *list) static unsigned char magic_id[] = {0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1}; -char * -cli_ole2_get_property_name2(const char *name, int size) +/** + * @brief Get the property name, converting to lower case and replacing non-printable characters. + * + * @param name The property name + * @param size The size of the property name + * @return char* The new property name + */ +char *cli_ole2_get_property_name2(const char *name, int size) { int i, j; char *newname = NULL; @@ -256,27 +262,35 @@ cli_ole2_get_property_name2(const char *name, int size) if ((name[0] == 0 && name[1] == 0) || size <= 0 || size > 128) { return NULL; } - CLI_MAX_MALLOC_OR_GOTO_DONE(newname, size * 7, - cli_errmsg("OLE2 [cli_ole2_get_property_name2]: Unable to allocate memory for newname: %u\n", size * 7)); + + // We may need to replace every character with '_XY_' or '_XYZ_' to form a printable name. + // This is because the name may contain non-printable characters. + // Allocate 5 times the size of the name to be safe, plus 1 for the NULL terminator. + CLI_MAX_MALLOC_OR_GOTO_DONE(newname, size * 5 + 1, + cli_errmsg("OLE2 [cli_ole2_get_property_name2]: Unable to allocate memory for newname: %u\n", size * 5)); j = 0; /* size-2 to ignore trailing NULL */ for (i = 0; i < size - 2; i += 2) { - if ((!(name[i] & 0x80)) && isprint(name[i]) && name[i + 1] == 0) { + if ((!(name[i] & 0x80)) && + (isprint(name[i])) && + (name[i + 1] == 0)) { + // Printable ASCII newname[j++] = tolower(name[i]); } else { + // Non-printable. Expand to something unique and printable. if (name[i] < 10 && name[i] >= 0 && name[i + 1] == 0) { + // Single digit (next byte is NULL) newname[j++] = '_'; newname[j++] = name[i] + '0'; } else { + // Two digits (next byte is not NULL) const uint16_t x = (((uint16_t)name[i]) << 8) | name[i + 1]; newname[j++] = '_'; newname[j++] = 'a' + ((x & 0xF)); newname[j++] = 'a' + ((x >> 4) & 0xF); newname[j++] = 'a' + ((x >> 8) & 0xF); - newname[j++] = 'a' + ((x >> 16) & 0xF); - newname[j++] = 'a' + ((x >> 24) & 0xF); } newname[j++] = '_'; } @@ -1726,7 +1740,7 @@ static cl_error_t handler_otf_encrypted(ole2_header_t *hdr, property_t *prop, co int nrounds = 0; uint8_t *decryptDst = NULL; encryption_key_t *key = (encryption_key_t *)handler_ctx; - uint64_t *rk = NULL; + uint32_t *rk = NULL; uint32_t bytesRead = 0; uint64_t actualFileLength; uint64_t bytesWritten = 0; @@ -1746,7 +1760,7 @@ static cl_error_t handler_otf_encrypted(ole2_header_t *hdr, property_t *prop, co goto done; } - CLI_MAX_MALLOC_OR_GOTO_DONE(rk, RKLENGTH(key->key_length_bits) * sizeof(uint64_t), ret = CL_EMEM); + CLI_MAX_MALLOC_OR_GOTO_DONE(rk, RKLENGTH(key->key_length_bits) * sizeof(uint32_t), ret = CL_EMEM); print_ole2_property(prop); @@ -2143,7 +2157,7 @@ static cl_error_t generate_key_aes(const char *const password, encryption_key_t static bool aes_128ecb_decrypt(const unsigned char *in, size_t length, unsigned char *out, const encryption_key_t *const key) { - uint64_t rk[RKLENGTH(128)]; + uint32_t rk[RKLENGTH(128)]; int nrounds; size_t i; bool bRet = false; diff --git a/libclamav/others.c b/libclamav/others.c index d032840c28..9e6f9cecdd 100644 --- a/libclamav/others.c +++ b/libclamav/others.c @@ -250,7 +250,7 @@ static void *get_module_function(HMODULE handle, const char *name) NULL, lasterr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPCSTR)&err, + (LPSTR)&err, 0, NULL); } @@ -1132,10 +1132,10 @@ void cli_append_potentially_unwanted_if_heur_exceedsmax(cli_ctx *ctx, char *vnam } } -cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, unsigned long need2, unsigned long need3) +cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, uint64_t need1, uint64_t need2, uint64_t need3) { cl_error_t ret = CL_SUCCESS; - unsigned long needed; + uint64_t needed; if (!ctx) { /* if called without limits, go on, unpack, scan */ @@ -1156,7 +1156,7 @@ cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, u /* Enforce global scan-size limit, if limit enabled */ if (needed && (ctx->engine->maxscansize != 0) && (ctx->engine->maxscansize - ctx->scansize < needed)) { /* The size needed is greater than the remaining scansize ... Skip this file. */ - cli_dbgmsg("%s: scansize exceeded (initial: %lu, consumed: %lu, needed: %lu)\n", who, (unsigned long int)ctx->engine->maxscansize, (unsigned long int)ctx->scansize, needed); + cli_dbgmsg("%s: scansize exceeded (initial: %lu, consumed: %lu, needed: %lu)\n", who, ctx->engine->maxscansize, ctx->scansize, needed); ret = CL_EMAXSIZE; cli_append_potentially_unwanted_if_heur_exceedsmax(ctx, "Heuristics.Limits.Exceeded.MaxScanSize"); goto done; @@ -1165,7 +1165,7 @@ cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, u /* Enforce per-file file-size limit, if limit enabled */ if (needed && (ctx->engine->maxfilesize != 0) && (ctx->engine->maxfilesize < needed)) { /* The size needed is greater than that limit ... Skip this file. */ - cli_dbgmsg("%s: filesize exceeded (allowed: %lu, needed: %lu)\n", who, (unsigned long int)ctx->engine->maxfilesize, needed); + cli_dbgmsg("%s: filesize exceeded (allowed: %lu, needed: %lu)\n", who, ctx->engine->maxfilesize, needed); ret = CL_EMAXSIZE; cli_append_potentially_unwanted_if_heur_exceedsmax(ctx, "Heuristics.Limits.Exceeded.MaxFileSize"); goto done; diff --git a/libclamav/others.h b/libclamav/others.h index 4c12d6ea30..bd852326f4 100644 --- a/libclamav/others.h +++ b/libclamav/others.h @@ -593,16 +593,16 @@ extern LIBCLAMAV_EXPORT int have_rar; /* based on macros from A. Melnikoff */ #define cbswap16(v) (((v & 0xff) << 8) | (((v) >> 8) & 0xff)) -#define cbswap32(v) ((((v)&0x000000ff) << 24) | (((v)&0x0000ff00) << 8) | \ - (((v)&0x00ff0000) >> 8) | (((v)&0xff000000) >> 24)) -#define cbswap64(v) ((((v)&0x00000000000000ffULL) << 56) | \ - (((v)&0x000000000000ff00ULL) << 40) | \ - (((v)&0x0000000000ff0000ULL) << 24) | \ - (((v)&0x00000000ff000000ULL) << 8) | \ - (((v)&0x000000ff00000000ULL) >> 8) | \ - (((v)&0x0000ff0000000000ULL) >> 24) | \ - (((v)&0x00ff000000000000ULL) >> 40) | \ - (((v)&0xff00000000000000ULL) >> 56)) +#define cbswap32(v) ((((v) & 0x000000ff) << 24) | (((v) & 0x0000ff00) << 8) | \ + (((v) & 0x00ff0000) >> 8) | (((v) & 0xff000000) >> 24)) +#define cbswap64(v) ((((v) & 0x00000000000000ffULL) << 56) | \ + (((v) & 0x000000000000ff00ULL) << 40) | \ + (((v) & 0x0000000000ff0000ULL) << 24) | \ + (((v) & 0x00000000ff000000ULL) << 8) | \ + (((v) & 0x000000ff00000000ULL) >> 8) | \ + (((v) & 0x0000ff0000000000ULL) >> 24) | \ + (((v) & 0x00ff000000000000ULL) >> 40) | \ + (((v) & 0xff00000000000000ULL) >> 56)) #ifndef HAVE_ATTRIB_PACKED #define __attribute__(x) @@ -828,8 +828,8 @@ size_t cli_recursion_stack_get_size(cli_ctx *ctx, int index); /* used by: spin, yc (C) aCaB */ #define __SHIFTBITS(a) (sizeof(a) << 3) #define __SHIFTMASK(a) (__SHIFTBITS(a) - 1) -#define CLI_ROL(a, b) a = (a << ((b)&__SHIFTMASK(a))) | (a >> ((__SHIFTBITS(a) - (b)) & __SHIFTMASK(a))) -#define CLI_ROR(a, b) a = (a >> ((b)&__SHIFTMASK(a))) | (a << ((__SHIFTBITS(a) - (b)) & __SHIFTMASK(a))) +#define CLI_ROL(a, b) a = (a << ((b) & __SHIFTMASK(a))) | (a >> ((__SHIFTBITS(a) - (b)) & __SHIFTMASK(a))) +#define CLI_ROR(a, b) a = (a >> ((b) & __SHIFTMASK(a))) | (a << ((__SHIFTBITS(a) - (b)) & __SHIFTMASK(a))) /* Implementation independent sign-extended signed right shift */ #ifdef HAVE_SAR @@ -1143,7 +1143,7 @@ int cli_bitset_set(bitset_t *bs, unsigned long bit_offset); int cli_bitset_test(bitset_t *bs, unsigned long bit_offset); const char *cli_ctime(const time_t *timep, char *buf, const size_t bufsize); -cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, unsigned long need2, unsigned long need3); +cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, uint64_t need1, uint64_t need2, uint64_t need3); /** * @brief Call before scanning a file to determine if we should scan it, skip it, or abort the entire scanning process. @@ -1157,7 +1157,6 @@ cl_error_t cli_checklimits(const char *who, cli_ctx *ctx, unsigned long need1, u */ cl_error_t cli_updatelimits(cli_ctx *ctx, size_t needed); -unsigned long cli_getsizelimit(cli_ctx *, unsigned long); int cli_matchregex(const char *str, const char *regex); void cli_qsort(void *a, size_t n, size_t es, int (*cmp)(const void *, const void *)); void cli_qsort_r(void *a, size_t n, size_t es, int (*cmp)(const void *, const void *, const void *), void *arg); @@ -1333,7 +1332,7 @@ uint8_t cli_set_debug_flag(uint8_t debug_flag); #define CLI_FREE_AND_SET_NULL(var) \ do { \ if (NULL != var) { \ - free(var); \ + free((void *)var); \ var = NULL; \ } \ } while (0) @@ -1461,16 +1460,16 @@ uint8_t cli_set_debug_flag(uint8_t debug_flag); * @param ... The error handling code to execute if the allocation fails. */ #ifndef CLI_MAX_REALLOC_OR_GOTO_DONE -#define CLI_MAX_REALLOC_OR_GOTO_DONE(ptr, size, ...) \ - do { \ - void *vTmp = cli_max_realloc(ptr, size); \ - if (NULL == vTmp) { \ - do { \ - __VA_ARGS__; \ - } while (0); \ - goto done; \ - } \ - ptr = vTmp; \ +#define CLI_MAX_REALLOC_OR_GOTO_DONE(ptr, size, ...) \ + do { \ + void *vTmp = cli_max_realloc((void *)ptr, size); \ + if (NULL == vTmp) { \ + do { \ + __VA_ARGS__; \ + } while (0); \ + goto done; \ + } \ + ptr = vTmp; \ } while (0) #endif @@ -1486,16 +1485,16 @@ uint8_t cli_set_debug_flag(uint8_t debug_flag); * @param ... The error handling code to execute if the allocation fails. */ #ifndef CLI_SAFER_REALLOC_OR_GOTO_DONE -#define CLI_SAFER_REALLOC_OR_GOTO_DONE(ptr, size, ...) \ - do { \ - void *vTmp = cli_safer_realloc(ptr, size); \ - if (NULL == vTmp) { \ - do { \ - __VA_ARGS__; \ - } while (0); \ - goto done; \ - } \ - ptr = vTmp; \ +#define CLI_SAFER_REALLOC_OR_GOTO_DONE(ptr, size, ...) \ + do { \ + void *vTmp = cli_safer_realloc((void *)ptr, size); \ + if (NULL == vTmp) { \ + do { \ + __VA_ARGS__; \ + } while (0); \ + goto done; \ + } \ + ptr = vTmp; \ } while (0) #endif diff --git a/libclamav/others_common.c b/libclamav/others_common.c index ce549f0787..60d0179d2d 100644 --- a/libclamav/others_common.c +++ b/libclamav/others_common.c @@ -980,7 +980,7 @@ static cl_error_t cli_ftw_dir(const char *dirname, int flags, int maxdepth, cli_ * used */ const char *cli_strerror(int errnum, char *buf, size_t len) { - char *err; + const char *err; #ifdef CL_THREAD_SAFE pthread_mutex_lock(&cli_strerror_mutex); #endif diff --git a/libclamav/pdf.c b/libclamav/pdf.c index 7f1e506e4f..49a1586c7d 100644 --- a/libclamav/pdf.c +++ b/libclamav/pdf.c @@ -632,9 +632,9 @@ cl_error_t pdf_findobj(struct pdf_struct *pdf) * * If this is the case, we can detect it and continue parsing after the %%EOF. */ - if (objid_search_index - strlen("\%\%EO") > start) { - const char *lastfile = objid_search_index - strlen("\%\%EO"); - if (0 != strncmp(lastfile, "\%\%EOF", 5)) { + if (objid_search_index - strlen("%%EO") > start) { + const char *lastfile = objid_search_index - strlen("%%EO"); + if (0 != strncmp(lastfile, "%%EOF", 5)) { /* Nope, wasn't %%EOF */ cli_dbgmsg("pdf_findobj: Failed to parse object objid (# objects found: %u)\n", pdf->nobjs); /* Skip past the "obj" thing, and continue. */ @@ -645,7 +645,7 @@ cl_error_t pdf_findobj(struct pdf_struct *pdf) /* Yup, Looks, like the file continues after %%EOF. * Probably another revision. Keep parsing... */ objid_search_index++; - cli_dbgmsg("pdf_findobj: \%\%EOF detected before end of file, at offset: %zu\n", (size_t)(objid_search_index - pdf->map)); + cli_dbgmsg("pdf_findobj: %%%%EOF detected before end of file, at offset: %zu\n", (size_t)(objid_search_index - pdf->map)); } else { /* Failed parsing at the very beginning */ cli_dbgmsg("pdf_findobj: Failed to parse object objid (# objects found: %u)\n", pdf->nobjs); @@ -742,8 +742,8 @@ static size_t filter_writen(struct pdf_struct *pdf, struct pdf_obj *obj, int fou { UNUSEDPARAM(obj); - if (cli_checklimits("pdf", pdf->ctx, (unsigned long)*sum, 0, 0)) /* TODO: May truncate for large values on 64-bit platforms */ - return len; /* pretend it was a successful write to suppress CL_EWRITE */ + if (cli_checklimits("pdf", pdf->ctx, (uint64_t)*sum, 0, 0)) + return len; *sum += len; @@ -1083,7 +1083,7 @@ static void dbg_printhex(const char *msg, const char *hex, unsigned len); static void aes_256cbc_decrypt(const unsigned char *in, size_t *length, unsigned char *q, char *key, unsigned key_n, int has_iv) { - unsigned long rk[RKLENGTH(256)]; + uint32_t rk[RKLENGTH(256)]; unsigned char iv[16]; size_t len = 0; unsigned char pad, i; @@ -1171,7 +1171,7 @@ static void aes_256cbc_decrypt(const unsigned char *in, size_t *length, unsigned static void aes_128cbc_encrypt(const unsigned char *in, size_t in_length, unsigned char *out, size_t *out_length, const unsigned char *key, size_t key_n, const unsigned char *iv) { - unsigned long rk[RKLENGTH(128)]; + uint32_t rk[RKLENGTH(128)]; unsigned char real_iv[16] = {0}; int nrounds; uint8_t i = 0; diff --git a/libclamav/rijndael.c b/libclamav/rijndael.c index 4e54aa5abe..e2db914536 100644 --- a/libclamav/rijndael.c +++ b/libclamav/rijndael.c @@ -3,10 +3,7 @@ #include "rijndael.h" -typedef unsigned long u32; -typedef unsigned char u8; - -static const u32 Te0[256] = +static const uint32_t Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, @@ -74,7 +71,7 @@ static const u32 Te0[256] = 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; -static const u32 Te1[256] = +static const uint32_t Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, @@ -142,7 +139,7 @@ static const u32 Te1[256] = 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; -static const u32 Te2[256] = +static const uint32_t Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, @@ -210,7 +207,7 @@ static const u32 Te2[256] = 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; -static const u32 Te3[256] = +static const uint32_t Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, @@ -278,7 +275,7 @@ static const u32 Te3[256] = 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; -static const u32 Te4[256] = +static const uint32_t Te4[256] = { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, @@ -346,7 +343,7 @@ static const u32 Te4[256] = 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; -static const u32 Td0[256] = +static const uint32_t Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, @@ -414,7 +411,7 @@ static const u32 Td0[256] = 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; -static const u32 Td1[256] = +static const uint32_t Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, @@ -482,7 +479,7 @@ static const u32 Td1[256] = 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; -static const u32 Td2[256] = +static const uint32_t Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, @@ -550,7 +547,7 @@ static const u32 Td2[256] = 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; -static const u32 Td3[256] = +static const uint32_t Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, @@ -618,7 +615,7 @@ static const u32 Td3[256] = 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; -static const u32 Td4[256] = +static const uint32_t Td4[256] = { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, @@ -686,7 +683,7 @@ static const u32 Td4[256] = 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; -static const u32 rcon[] = +static const uint32_t rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, @@ -694,28 +691,28 @@ static const u32 rcon[] = /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; -#define GETU32(plaintext) (((u32)(plaintext)[0] << 24) ^ \ - ((u32)(plaintext)[1] << 16) ^ \ - ((u32)(plaintext)[2] << 8) ^ \ - ((u32)(plaintext)[3])) +#define GETU32(plaintext) (((uint32_t)(plaintext)[0] << 24) ^ \ + ((uint32_t)(plaintext)[1] << 16) ^ \ + ((uint32_t)(plaintext)[2] << 8) ^ \ + ((uint32_t)(plaintext)[3])) -#define PUTU32(ciphertext, st) { (ciphertext)[0] = (u8)((st) >> 24); \ - (ciphertext)[1] = (u8)((st) >> 16); \ - (ciphertext)[2] = (u8)((st) >> 8); \ - (ciphertext)[3] = (u8)(st); } +#define PUTU32(ciphertext, st) { (ciphertext)[0] = (uint8_t)((st) >> 24); \ + (ciphertext)[1] = (uint8_t)((st) >> 16); \ + (ciphertext)[2] = (uint8_t)((st) >> 8); \ + (ciphertext)[3] = (uint8_t)(st); } -int rijndaelSetupEncrypt(u32 *rk, const u8 *key, int keybits); -void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16], u8 ciphertext[16]); +int rijndaelSetupEncrypt(uint32_t *rk, const uint8_t *key, int keybits); +void rijndaelEncrypt(const uint32_t *rk, int nrounds, const uint8_t plaintext[16], uint8_t ciphertext[16]); /** * Expand the cipher key into the encryption key schedule. * * @return the number of rounds for the given cipher key size. */ -int rijndaelSetupEncrypt(u32 *rk, const u8 *key, int keybits) +int rijndaelSetupEncrypt(uint32_t *rk, const uint8_t *key, int keybits) { int i = 0; - u32 temp; + uint32_t temp; rk[0] = GETU32(key ); rk[1] = GETU32(key + 4); @@ -801,10 +798,10 @@ int rijndaelSetupEncrypt(u32 *rk, const u8 *key, int keybits) * * @return the number of rounds for the given cipher key size. */ -int rijndaelSetupDecrypt(u32 *rk, const u8 *key, int keybits) +int rijndaelSetupDecrypt(uint32_t *rk, const uint8_t *key, int keybits) { int nrounds, i, j; - u32 temp; + uint32_t temp; /* expand the cipher key: */ nrounds = rijndaelSetupEncrypt(rk, key, keybits); @@ -844,10 +841,10 @@ int rijndaelSetupDecrypt(u32 *rk, const u8 *key, int keybits) return nrounds; } -void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16], - u8 ciphertext[16]) +void rijndaelEncrypt(const uint32_t *rk, int nrounds, const uint8_t plaintext[16], + uint8_t ciphertext[16]) { - u32 s0, s1, s2, s3, t0, t1, t2, t3; + uint32_t s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ @@ -1026,10 +1023,10 @@ void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16], PUTU32(ciphertext + 12, s3); } -void rijndaelDecrypt(const u32 *rk, int nrounds, const u8 ciphertext[16], - u8 plaintext[16]) +void rijndaelDecrypt(const uint32_t *rk, int nrounds, const uint8_t ciphertext[16], + uint8_t plaintext[16]) { - u32 s0, s1, s2, s3, t0, t1, t2, t3; + uint32_t s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ @@ -1208,4 +1205,3 @@ void rijndaelDecrypt(const u32 *rk, int nrounds, const u8 ciphertext[16], rk[3]; PUTU32(plaintext + 12, s3); } - diff --git a/libclamav/rijndael.h b/libclamav/rijndael.h index 153673cd54..cc6d8cad05 100644 --- a/libclamav/rijndael.h +++ b/libclamav/rijndael.h @@ -1,15 +1,17 @@ +/* public domain code from http://www.efgh.com/software/rijndael.htm */ #ifndef H__RIJNDAEL #define H__RIJNDAEL -int rijndaelSetupDecrypt(unsigned long *rk, const unsigned char *key, int keybits); -void rijndaelDecrypt(const unsigned long *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]); +#include "clamav-types.h" -int rijndaelSetupEncrypt(unsigned long *rk, const unsigned char *key, int keybits); -void rijndaelEncrypt(const unsigned long *rk, int nrounds, const unsigned char plaintext[16], unsigned char ciphertext[16]); +int rijndaelSetupDecrypt(uint32_t *rk, const unsigned char *key, int keybits); +void rijndaelDecrypt(const uint32_t *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]); + +int rijndaelSetupEncrypt(uint32_t *rk, const unsigned char *key, int keybits); +void rijndaelEncrypt(const uint32_t *rk, int nrounds, const unsigned char plaintext[16], unsigned char ciphertext[16]); #define KEYLENGTH(keybits) ((keybits)/8) #define RKLENGTH(keybits) ((keybits)/8+28) #define NROUNDS(keybits) ((keybits)/32+6) #endif - diff --git a/libclamav/scanners.c b/libclamav/scanners.c index e5152da56b..34544323b3 100644 --- a/libclamav/scanners.c +++ b/libclamav/scanners.c @@ -205,7 +205,7 @@ static cl_error_t cli_unrar_scanmetadata(unrar_metadata_t *metadata, cli_ctx *ct (unsigned int)metadata->unpack_size, metadata->method, metadata->pack_size ? (unsigned int)(metadata->unpack_size / metadata->pack_size) : 0); - if (CL_VIRUS == cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, metadata->crc, NULL)) { + if (CL_VIRUS == cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, metadata->crc)) { status = CL_VIRUS; } else if (SCAN_HEURISTIC_ENCRYPTED_ARCHIVE && metadata->encrypted) { cli_dbgmsg("RAR: Encrypted files found in archive.\n"); @@ -610,7 +610,7 @@ static cl_error_t cli_egg_scanmetadata(cl_egg_metadata *metadata, cli_ctx *ctx, (unsigned int)metadata->unpack_size, metadata->pack_size ? (unsigned int)(metadata->unpack_size / metadata->pack_size) : 0); - if (CL_VIRUS == cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, 0, NULL)) { + if (CL_VIRUS == cli_matchmeta(ctx, metadata->filename, metadata->pack_size, metadata->unpack_size, metadata->encrypted, files, 0)) { status = CL_VIRUS; } else if (SCAN_HEURISTIC_ENCRYPTED_ARCHIVE && metadata->encrypted) { cli_dbgmsg("EGG: Encrypted files found in archive.\n"); @@ -1011,7 +1011,7 @@ static cl_error_t cli_scanarj(cli_ctx *ctx) file++; - if (CL_VIRUS == cli_matchmeta(ctx, metadata.filename, metadata.comp_size, metadata.orig_size, metadata.encrypted, file, 0, NULL)) { + if (CL_VIRUS == cli_matchmeta(ctx, metadata.filename, metadata.comp_size, metadata.orig_size, metadata.encrypted, file, 0)) { cli_rmdirs(dir); free(dir); return CL_VIRUS; @@ -1556,8 +1556,6 @@ static cl_error_t vba_scandata(const unsigned char *data, size_t len, cli_ctx *c return ret; } -#define min(x, y) ((x) < (y) ? (x) : (y)) - /** * Find a file in a directory tree. * \param filename Name of the file to find @@ -1596,7 +1594,7 @@ cl_error_t find_file(const char *filename, const char *dir, char *result, size_t } } else if (S_ISREG(statbuf.st_mode)) { if (strcmp(dent->d_name, filename) == 0) { - len = min(strlen(dir) + 1, result_size); + len = MIN(strlen(dir) + 1, result_size); memcpy(result, dir, len); result[len - 1] = '\0'; closedir(dd); @@ -4587,6 +4585,11 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type) ret = scan_onenote(ctx); break; + case CL_TYPE_LHA_LZH: + if (SCAN_PARSE_ARCHIVE && (DCONF_ARCH & ARCH_CONF_LHA_LZH)) + ret = scan_lha_lzh(ctx); + break; + case CL_TYPE_OOXML_WORD: case CL_TYPE_OOXML_PPT: case CL_TYPE_OOXML_XL: diff --git a/libclamav/sis.c b/libclamav/sis.c index 7c277b4358..c3de1983c0 100644 --- a/libclamav/sis.c +++ b/libclamav/sis.c @@ -166,14 +166,14 @@ enum { else { \ if ((N) < sleft) { \ cli_dbgmsg("SIS: Refusing to seek back\n"); \ - free(alangs); \ + free((void *)alangs); \ return CL_CLEAN; \ } \ pos += (N)-sleft; \ size_t tmp = fmap_readn(map, buff, pos, BUFSIZ); \ if (((size_t)-1) == tmp) { \ cli_dbgmsg("SIS: Read failed during SKIP\n"); \ - free(alangs); \ + free((void *)alangs); \ return CL_CLEAN; \ } \ sleft = smax = tmp; \ @@ -628,7 +628,7 @@ enum { T_INVALID, const char *sisfields[] = {"Invalid", "String", "Array", "Compressed", "Version", "VersionRange", "Date", "Time", "DateTime", "Uid", "Unused", "Language", "Contents", "Controller", "Info", "SupportedLanguages", "SupportedOptions", "Prerequisites", "Dependency", "Properties", "Property", "Signatures", "CertificateChain", "Logo", "FileDescription", "Hash", "If", "ElseIf", "InstallBlock", "Expression", "Data", "DataUnit", "FileData", "SupportedOption", "ControllerChecksum", "DataChecksum", "Signature", "Blob", "SignatureAlgorithm", "SignatureCertificateChain", "DataIndex", "Capabilities"}; -#define ALIGN4(x) (((x) & ~3) + ((((x)&1) | (((x) >> 1) & 1)) << 2)) +#define ALIGN4(x) (((x) & ~3) + ((((x) & 1) | (((x) >> 1) & 1)) << 2)) #define HERE printf("here\n"), abort(); diff --git a/libclamav/untar.c b/libclamav/untar.c index d022c74c42..aea8aea61c 100644 --- a/libclamav/untar.c +++ b/libclamav/untar.c @@ -302,7 +302,7 @@ cl_error_t cli_untar(const char *dir, unsigned int posix, cli_ctx *ctx) strncpy(name, block, 100); name[100] = '\0'; - if (cli_matchmeta(ctx, name, size, size, 0, files, 0, NULL) == CL_VIRUS) { + if (cli_matchmeta(ctx, name, size, size, 0, files, 0) == CL_VIRUS) { return CL_VIRUS; } @@ -331,7 +331,7 @@ cl_error_t cli_untar(const char *dir, unsigned int posix, cli_ctx *ctx) if (limitnear > 0) { currsize += nbytes; cli_dbgmsg("cli_untar: Approaching limit...\n"); - if (cli_checklimits("cli_untar", ctx, (unsigned long)currsize, 0, 0) != CL_SUCCESS) { + if (cli_checklimits("cli_untar", ctx, (uint64_t)currsize, 0, 0) != CL_SUCCESS) { // Limit would be exceeded by this file, suppress writing beyond limit // Need to keep reading to get to end of file chunk skipwrite++; diff --git a/libclamav/unzip.c b/libclamav/unzip.c index 189ce72461..74fe0c120e 100644 --- a/libclamav/unzip.c +++ b/libclamav/unzip.c @@ -671,7 +671,7 @@ static unsigned int parse_local_file_header( /* ZMDfmt virname:encrypted(0-1):filename(exact|*):usize(exact|*):csize(exact|*):crc32(exact|*):method(exact|*):fileno(exact|*):maxdepth(exact|*) */ /* Scan file header metadata. */ - if (cli_matchmeta(ctx, name, LOCAL_HEADER_csize, LOCAL_HEADER_usize, (LOCAL_HEADER_flags & F_ENCR) != 0, file_count, LOCAL_HEADER_crc32, NULL) == CL_VIRUS) { + if (cli_matchmeta(ctx, name, LOCAL_HEADER_csize, LOCAL_HEADER_usize, (LOCAL_HEADER_flags & F_ENCR) != 0, file_count, LOCAL_HEADER_crc32) == CL_VIRUS) { *ret = CL_VIRUS; goto done; } @@ -861,7 +861,7 @@ parse_central_directory_file_header( coff += CENTRAL_HEADER_flen; /* requests do not supply a ctx; also prevent multiple scans */ - if (ctx && (CL_VIRUS == cli_matchmeta(ctx, name, CENTRAL_HEADER_csize, CENTRAL_HEADER_usize, (CENTRAL_HEADER_flags & F_ENCR) != 0, file_count, CENTRAL_HEADER_crc32, NULL))) { + if (ctx && (CL_VIRUS == cli_matchmeta(ctx, name, CENTRAL_HEADER_csize, CENTRAL_HEADER_usize, (CENTRAL_HEADER_flags & F_ENCR) != 0, file_count, CENTRAL_HEADER_crc32))) { last = 1; *ret = CL_VIRUS; goto done; diff --git a/libclamav_rust/Cargo.toml b/libclamav_rust/Cargo.toml index 26a3a22b3a..2d9f27e3e1 100644 --- a/libclamav_rust/Cargo.toml +++ b/libclamav_rust/Cargo.toml @@ -16,12 +16,13 @@ image = "0.24" rustdct = "0.7" transpose = "0.2" num-traits = "0.2" -base64 = "0.21.0" -sha1 = "0.10.5" -unicode-segmentation = "1.10.1" +base64 = "0.21" +sha1 = "0.10" +unicode-segmentation = "1.10" bindgen = "0.65" onenote_parser = { git = "https://github.com/Cisco-Talos/onenote.rs.git", branch = "CLAM-2329-new-from-slice" } -hex-literal = "0.4.1" +hex-literal = "0.4" +delharc = "0.5" [lib] crate-type = ["staticlib"] diff --git a/libclamav_rust/build.rs b/libclamav_rust/build.rs index 36dd19dd77..21e31f1a1e 100644 --- a/libclamav_rust/build.rs +++ b/libclamav_rust/build.rs @@ -53,6 +53,8 @@ const BINDGEN_FUNCTIONS: &[&str] = &[ "cli_getdsig", "cli_get_debug_flag", "cli_magic_scan_buff", + "cli_checklimits", + "cli_matchmeta", ]; // Generate bindings for these types (structs, enums): diff --git a/libclamav_rust/src/scanners.rs b/libclamav_rust/src/scanners.rs index 44795f195d..554205c9e5 100644 --- a/libclamav_rust/src/scanners.rs +++ b/libclamav_rust/src/scanners.rs @@ -22,17 +22,24 @@ use std::{ ffi::{c_char, CString}, + io::Read, + panic, path::Path, ptr::null_mut, }; +use delharc::LhaDecodeReader; use libc::c_void; use log::{debug, error, warn}; use crate::{ ctx, onenote::OneNote, - sys::{cl_error_t, cl_error_t_CL_ERROR, cl_error_t_CL_SUCCESS, cli_ctx, cli_magic_scan_buff}, + sys::{ + cl_error_t, cl_error_t_CL_EFORMAT, cl_error_t_CL_ERROR, cl_error_t_CL_SUCCESS, cli_ctx, + cli_magic_scan_buff, + }, + util::{check_scan_limits, scan_archive_metadata}, }; /// Rust wrapper of libclamav's cli_magic_scan_buff() function. @@ -127,3 +134,164 @@ pub unsafe extern "C" fn scan_onenote(ctx: *mut cli_ctx) -> cl_error_t { scan_result } + +/// Scan the contents of a LHA or LZH archive +/// +/// # Safety +/// +/// Must be a valid ctx pointer. +#[no_mangle] +pub unsafe extern "C" fn scan_lha_lzh(ctx: *mut cli_ctx) -> cl_error_t { + let fmap = match ctx::current_fmap(ctx) { + Ok(fmap) => fmap, + Err(e) => { + warn!("Error getting FMap from ctx: {e}"); + return cl_error_t_CL_ERROR; + } + }; + + let file_bytes = match fmap.need_off(0, fmap.len()) { + Ok(bytes) => bytes, + Err(err) => { + error!( + "Failed to get file bytes for fmap of size {}: {err}", + fmap.len() + ); + return cl_error_t_CL_ERROR; + } + }; + + // Try to parse the LHA/LZH file data using the delharc crate. + debug!("Attempting to parse the LHA/LZH file data using the delharc crate."); + + // Attempt to catch panics in case the parser encounter unexpected issues. + let result_result = panic::catch_unwind( + || -> Result, delharc::decode::LhaDecodeError<&[u8]>> { + LhaDecodeReader::new(file_bytes) + }, + ); + + // Check if it panicked. If no panic, grab the parse result. + let result = match result_result { + Ok(result) => result, + Err(_) => { + debug!("Panic occurred when trying to open LHA archive with delharc crate"); + return cl_error_t_CL_EFORMAT; + } + }; + + // Check if any issue opening the archive. + let mut decoder = match result { + Ok(result) => result, + Err(err) => { + debug!("Unable to parse LHA archive with delharc crate: {err}"); + return cl_error_t_CL_EFORMAT; + } + }; + + debug!("Opened the LHA/LZH archive"); + + let mut index: usize = 0; + loop { + // Check if we've already exceeded the limits and should bail out. + let ret = check_scan_limits("LHA", ctx, 0, 0, 0); + if ret != cl_error_t_CL_SUCCESS { + debug!("Exceeded scan limits. Bailing out."); + break; + } + + // Get the file header. + let header = decoder.header(); + + // Verify the CRC check. This is important because LHA/LZH does not have particularly identifiable magic bytes. + match decoder.crc_check() { + Ok(crc) => { + // CRC is valid. Very likely it is indeed an LHA/LZH archive. + debug!("CRC check passed. Very likely this is an LHA or LZH archive. CRC: {crc}"); + } + Err(err) => { + // Error checking CRC. + // Use debug-level because may not actually be an LHA/LZH archive. + // LHA/LZH does not have particularly identifiable magic bytes. + debug!("An error occurred when checking the CRC of this LHA or LZH archive: {err}"); + // break; + } + } + + let filepath = header.parse_pathname(); + let filename = filepath.to_string_lossy(); + if header.is_directory() { + debug!("Skipping directory {filename}"); + } else { + debug!("Found file in LHA archive: {filename}"); + + // Scan the archive metadata first. + if scan_archive_metadata( + ctx, + &filename, + header.compressed_size as usize, + header.original_size as usize, + false, + index, + header.file_crc as i32, + ) != cl_error_t_CL_SUCCESS + { + debug!("Extracted file '{filename}' would exceed size limits. Skipping."); + } else { + // Check if scanning the next file would exceed the limits and should be skipped. + if check_scan_limits("LHA", ctx, header.original_size, 0, 0) + != cl_error_t_CL_SUCCESS + { + debug!("Extracted file '{filename}' would exceed size limits. Skipping."); + } else { + if !decoder.is_decoder_supported() { + debug!("err: unsupported compression method"); + } else { + // Read the file into a buffer. + let mut file_data = Vec::::new(); + + match decoder.read_to_end(&mut file_data) { + Ok(bytes_read) => { + if bytes_read > 0 { + let ret = + magic_scan(ctx, &file_data, Some(filename.to_string())); + if ret != cl_error_t_CL_SUCCESS { + debug!("cl_scandesc_magic returned error: {}", ret); + return ret; + } + } else { + debug!("Read zero-byte file."); + } + } + err => { + debug!("Error reading file {err:?}"); + } + } + } + } + } + + index += 1; + } + + // Get the next file. + match decoder.next_file() { + Ok(true) => { + debug!("Found another file in the archive!"); + } + Ok(false) => { + debug!("No more files in the archive."); + break; + } + Err(err) => { + // Error getting the next file. + // Use debug-level because may not actually be an LHA/LZH archive. + // LHA/LZH does not have particularly identifiable magic bytes. + debug!("An error occurred when checking for the next file in this LHA or LZH archive: {err}"); + break; + } + } + } + + cl_error_t_CL_SUCCESS +} diff --git a/libclamav_rust/src/sys.rs b/libclamav_rust/src/sys.rs index 6400b911ba..399ec438a4 100644 --- a/libclamav_rust/src/sys.rs +++ b/libclamav_rust/src/sys.rs @@ -807,6 +807,15 @@ extern "C" { extern "C" { pub fn cli_dbgmsg_no_inline(str_: *const ::std::os::raw::c_char, ...); } +extern "C" { + pub fn cli_checklimits( + who: *const ::std::os::raw::c_char, + ctx: *mut cli_ctx, + need1: u64, + need2: u64, + need3: u64, + ) -> cl_error_t; +} extern "C" { #[doc = " @brief Get the libclamav debug flag (e.g. if debug logging is enabled)\n\n This is required for unit tests to be able to link with clamav.dll and not\n directly manipulate libclamav global variables."] pub fn cli_get_debug_flag() -> u8; @@ -1158,6 +1167,17 @@ pub struct cli_cdb { pub res2: *mut ::std::os::raw::c_void, pub next: *mut cli_cdb, } +extern "C" { + pub fn cli_matchmeta( + ctx: *mut cli_ctx, + fname: *const ::std::os::raw::c_char, + fsizec: usize, + fsizer: usize, + encrypted: ::std::os::raw::c_int, + filepos: ::std::os::raw::c_uint, + res1: ::std::os::raw::c_int, + ) -> cl_error_t; +} extern "C" { pub fn cli_versig2( sha256: *const ::std::os::raw::c_uchar, diff --git a/libclamav_rust/src/util.rs b/libclamav_rust/src/util.rs index 0ecd879f92..086fdf2786 100644 --- a/libclamav_rust/src/util.rs +++ b/libclamav_rust/src/util.rs @@ -22,6 +22,10 @@ use std::{ffi::CStr, fs::File}; +use log::error; + +use crate::sys; + /// Obtain a std::fs::File from an i32 in a platform-independent manner. /// /// On Unix-like platforms, this is done with File::from_raw_fd(). @@ -47,7 +51,7 @@ pub fn file_from_fd_or_handle(fd: i32) -> File { compile_error!("implemented only for unix and windows targets") } -/// Get a string from a pointer +/// Get a string from a pointer. /// /// # Safety /// @@ -55,10 +59,72 @@ pub fn file_from_fd_or_handle(fd: i32) -> File { /// exceeds the lifetime of the output string. /// /// ptr must be a valid pointer to a C string. -pub unsafe fn str_from_ptr(ptr: *const ::std::os::raw::c_char) -> Result, std::str::Utf8Error> { +pub unsafe fn str_from_ptr( + ptr: *const ::std::os::raw::c_char, +) -> Result, std::str::Utf8Error> { if ptr.is_null() { return Ok(None); } Some(unsafe { CStr::from_ptr(ptr) }.to_str()).transpose() } + +/// Check scan limits in case we need to abort the scan. +/// +/// # Safety +/// +/// ctx must be a valid pointer to a clamav scan context structure +/// +pub unsafe fn check_scan_limits( + module_name: &str, + ctx: *mut sys::cli_ctx, + need1: u64, + need2: u64, + need3: u64, +) -> sys::cl_error_t { + let module_name = match std::ffi::CString::new(module_name) { + Ok(name) => name, + Err(_) => { + error!("Invalid module_name: {}", module_name); + return sys::cl_error_t_CL_EFORMAT; + } + }; + + unsafe { sys::cli_checklimits(module_name.as_ptr(), ctx, need1, need2, need3) } +} + +/// Scan archive metadata. +/// +/// # Safety +/// +/// ctx must be a valid pointer to a clamav scan context structure +/// +pub unsafe fn scan_archive_metadata( + ctx: *mut sys::cli_ctx, + filename: &str, + filesize_compressed: usize, + filesize_original: usize, + is_encrypted: bool, + filepos: usize, + res1: i32, +) -> sys::cl_error_t { + let module_name = match std::ffi::CString::new(filename) { + Ok(name) => name, + Err(_) => { + error!("Invalid module_name: {}", filename); + return sys::cl_error_t_CL_EFORMAT; + } + }; + + unsafe { + sys::cli_matchmeta( + ctx, + module_name.as_ptr(), + filesize_compressed, + filesize_original, + i32::from(is_encrypted), + filepos as u32, + res1, + ) + } +} diff --git a/unit_tests/check_clamav.c b/unit_tests/check_clamav.c index 0a46e7d45d..36e9a08e10 100644 --- a/unit_tests/check_clamav.c +++ b/unit_tests/check_clamav.c @@ -2027,12 +2027,15 @@ static void check_version_compatible() } #endif -int main(void) +int main(int argc, char **argv) { int nf; Suite *s; SRunner *sr; + UNUSEDPARAM(argc); + UNUSEDPARAM(argv); + cl_initialize_crypto(); fpu_words = get_fpu_endian(); diff --git a/unit_tests/check_clamd.c b/unit_tests/check_clamd.c index 78b90b637c..2f526709a7 100644 --- a/unit_tests/check_clamd.c +++ b/unit_tests/check_clamd.c @@ -890,10 +890,13 @@ static Suite *test_clamd_suite(void) return s; } -int main(void) +int main(int argc, char **argv) { int num_fds; + UNUSEDPARAM(argc); + UNUSEDPARAM(argv); + #ifdef _WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { diff --git a/unit_tests/check_jsnorm.c b/unit_tests/check_jsnorm.c index 7763e7cb4f..50939ba88d 100644 --- a/unit_tests/check_jsnorm.c +++ b/unit_tests/check_jsnorm.c @@ -114,7 +114,7 @@ END_TEST START_TEST(test_token_scope) { - struct scope *sc = (struct scope *)0xdeadbeef; + struct scope *sc = (struct scope *)(uint64_t)0xdeadbeef; yystype tok; memset(&tok, 0, sizeof(tok)); diff --git a/unit_tests/check_regex.c b/unit_tests/check_regex.c index 56593dee72..db24de6616 100644 --- a/unit_tests/check_regex.c +++ b/unit_tests/check_regex.c @@ -143,7 +143,7 @@ START_TEST(test_suffix) ck_assert_msg(!!pattern, "test pattern"); preg = malloc(sizeof(*regex.preg)); ck_assert_msg(!!preg, "malloc"); - rc = cli_regex2suffix(pattern, preg, cb_expect_multi, tests[_i]); + rc = cli_regex2suffix(pattern, preg, cb_expect_multi, (void *)tests[_i]); ck_assert_msg(rc == CL_SUCCESS, "single character pattern"); cli_regfree(preg); free(preg); diff --git a/unit_tests/clamscan/lzh_lha_archive_test.py b/unit_tests/clamscan/lzh_lha_archive_test.py new file mode 100644 index 0000000000..7214bef6c0 --- /dev/null +++ b/unit_tests/clamscan/lzh_lha_archive_test.py @@ -0,0 +1,59 @@ +# Copyright (C) 2020-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + +""" +Run clamscan tests. +""" + +import sys + +sys.path.append('../unit_tests') +import testcase + + +class TC(testcase.TestCase): + @classmethod + def setUpClass(cls): + super(TC, cls).setUpClass() + + # Testing with our logo png file. + TC.testfiles = list(TC.path_source.glob('unit_tests/input/other_scanfiles/lha_lzh/*.lzh')) + + @classmethod + def tearDownClass(cls): + super(TC, cls).tearDownClass() + + def setUp(self): + super(TC, self).setUp() + + def tearDown(self): + super(TC, self).tearDown() + self.verify_valgrind_log() + + def test_good_archives(self): + self.step_name('Verify that these LHA archives containing logo.png and cisco-logo.png correctly extract each.') + + (TC.path_tmp / 'good.ldb').write_text( + "logo.png;Engine:150-255,Target:0;0;fuzzy_img#af2ad01ed42993c7#0\n" + "cisco-logo.png;Engine:150-255,Target:0;0;fuzzy_img#9463944473afd82f#0\n" + ) + + testfiles = ' '.join([str(testfile) for testfile in TC.testfiles]) + + command = '{valgrind} {valgrind_args} {clamscan} -d {path_db} {testfiles} --allmatch'.format( + valgrind=TC.valgrind, valgrind_args=TC.valgrind_args, clamscan=TC.clamscan, + path_db=TC.path_tmp / 'good.ldb', + testfiles=testfiles, + ) + output = self.execute_command(command) + + assert output.ec == 1 # virus + assert output.out.count(' logo.png.UNOFFICIAL FOUND') == len(TC.testfiles) + assert output.out.count(' cisco-logo.png.UNOFFICIAL FOUND') == len(TC.testfiles) + + expected_stdout = [ + 'logo.png.UNOFFICIAL FOUND', + ] + unexpected_stdout = [ + 'OK', + ] + self.verify_output(output.out, expected=expected_stdout) diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh new file mode 100755 index 0000000000..32e704ef65 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh new file mode 100755 index 0000000000..792c854c56 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh new file mode 100755 index 0000000000..f6f9da3d94 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh b/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh new file mode 100755 index 0000000000..1fb17133e3 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh new file mode 100755 index 0000000000..13e13a6d26 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh new file mode 100755 index 0000000000..86398dbbf4 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh new file mode 100755 index 0000000000..f3a6076d36 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh new file mode 100755 index 0000000000..b4b5859a06 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh new file mode 100755 index 0000000000..2f1a3bcab4 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh b/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh differ diff --git a/unit_tests/valgrind.supp b/unit_tests/valgrind.supp index 8b59109824..1222870043 100644 --- a/unit_tests/valgrind.supp +++ b/unit_tests/valgrind.supp @@ -320,7 +320,6 @@ statx(file_name) fun:statx fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* ... } { @@ -329,7 +328,6 @@ statx(buf) fun:statx fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* ... } { @@ -338,7 +336,6 @@ statx(file_name) fun:syscall fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* ... } { @@ -347,7 +344,6 @@ statx(buf) fun:syscall fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* ... } { @@ -357,7 +353,6 @@ fun:__fxstatat fun:statx_generic* fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* ... } { @@ -368,7 +363,7 @@ fun:statx_generic* fun:statx fun:statx - fun:_ZN3std3sys4unix2fs9try_statx* + ... } { diff --git a/win32/compat/net.c b/win32/compat/net.c index 9f442a6bb9..792a848626 100644 --- a/win32/compat/net.c +++ b/win32/compat/net.c @@ -355,7 +355,7 @@ int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, s return ret; } -int w32_accept(SOCKET sockfd, const struct sockaddr *addr, socklen_t *addrlen) +int w32_accept(SOCKET sockfd, struct sockaddr *addr, socklen_t *addrlen) { if ((sockfd = accept(sockfd, addr, addrlen)) == INVALID_SOCKET) { wsock2errno(); diff --git a/win32/compat/net.h b/win32/compat/net.h index 4b928d2644..f2eadef79f 100644 --- a/win32/compat/net.h +++ b/win32/compat/net.h @@ -53,7 +53,7 @@ void w32_freeaddrinfo(struct addrinfo *res); const char *w32_inet_ntop(int af, const void *src, char *dst, socklen_t size); int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event); -int w32_accept(SOCKET sockfd, const struct sockaddr *addr, socklen_t *addrlen); +int w32_accept(SOCKET sockfd, struct sockaddr *addr, socklen_t *addrlen); int w32_listen(int sockfd, int backlog); int w32_shutdown(int sockfd, int how); int w32_getpeername(int sd, struct sockaddr *name, int *namelen); diff --git a/win32/compat/utf8_util.c b/win32/compat/utf8_util.c index 13e077ee4d..d5fe20a108 100644 --- a/win32/compat/utf8_util.c +++ b/win32/compat/utf8_util.c @@ -30,10 +30,10 @@ char *cli_strdup_to_utf8(const char *s) { - char *r = cli_to_utf8_maybe_alloc(s); + const char *r = cli_to_utf8_maybe_alloc(s); if (!r) return NULL; if (r == s) return _strdup(r); - return r; + return (char *)r; } #define MAYBE_FREE_W \ @@ -44,7 +44,7 @@ char *cli_strdup_to_utf8(const char *s) do { \ if (utf8 != tmpu) free(utf8); \ } while (0) -char *cli_to_utf8_maybe_alloc(const char *s) +const char *cli_to_utf8_maybe_alloc(const char *s) { int len = strlen(s) + 1; wchar_t tmpw[1024], *wdup; diff --git a/win32/compat/utf8_util.h b/win32/compat/utf8_util.h index 96db15fe9b..24bd1cf36a 100644 --- a/win32/compat/utf8_util.h +++ b/win32/compat/utf8_util.h @@ -26,7 +26,7 @@ #include #include -char *cli_to_utf8_maybe_alloc(const char *s); +const char *cli_to_utf8_maybe_alloc(const char *s); char *cli_strdup_to_utf8(const char *s); #endif diff --git a/win32/compat/w32_errno.c b/win32/compat/w32_errno.c index a8272c06e1..a4a211a745 100644 --- a/win32/compat/w32_errno.c +++ b/win32/compat/w32_errno.c @@ -22,7 +22,7 @@ #include #include "w32_errno.h" -char *w32_strerror(int errnum) +const char *w32_strerror(int errnum) { size_t i; for (i = 0; i < sizeof(w32_errnos) / sizeof(w32_errnos[0]); i++) { diff --git a/win32/compat/w32_errno.h b/win32/compat/w32_errno.h index 700fb31371..5e3e585632 100644 --- a/win32/compat/w32_errno.h +++ b/win32/compat/w32_errno.h @@ -28,7 +28,7 @@ #include #include "w32_errno_defs.c" -char *w32_strerror(int errnum); +const char *w32_strerror(int errnum); int w32_strerror_r(int errnum, char *buf, size_t buflen); #endif