|
| 1 | +/** |
| 2 | + * https://github.com/zlib-ng/minizip-ng |
| 3 | + */ |
| 4 | + |
| 5 | +import cpp |
| 6 | +import DecompressionBomb |
| 7 | + |
| 8 | +/** |
| 9 | + * The `mz_zip_entry` function is used in flow sink. |
| 10 | + * See https://github.com/zlib-ng/minizip-ng/blob/master/doc/mz_zip.md. |
| 11 | + */ |
| 12 | +class Mz_zip_entry extends DecompressionFunction { |
| 13 | + Mz_zip_entry() { this.hasGlobalName("mz_zip_entry_read") } |
| 14 | + |
| 15 | + override int getArchiveParameterIndex() { result = 1 } |
| 16 | +} |
| 17 | + |
| 18 | +/** |
| 19 | + * The `mz_zip_reader_entry_*` and `mz_zip_reader_save_all` functions are used in flow sink. |
| 20 | + * See https://github.com/zlib-ng/minizip-ng/blob/master/doc/mz_zip_rw.md. |
| 21 | + */ |
| 22 | +class Mz_zip_reader_entry extends DecompressionFunction { |
| 23 | + Mz_zip_reader_entry() { |
| 24 | + this.hasGlobalName([ |
| 25 | + "mz_zip_reader_entry_save", "mz_zip_reader_entry_read", "mz_zip_reader_entry_save_process", |
| 26 | + "mz_zip_reader_entry_save_file", "mz_zip_reader_entry_save_buffer", "mz_zip_reader_save_all" |
| 27 | + ]) |
| 28 | + } |
| 29 | + |
| 30 | + override int getArchiveParameterIndex() { result = 0 } |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * The `UnzOpen*` functions are used in flow sink. |
| 35 | + */ |
| 36 | +class UnzOpenFunction extends DecompressionFunction { |
| 37 | + UnzOpenFunction() { this.hasGlobalName(["UnzOpen", "unzOpen64", "unzOpen2", "unzOpen2_64"]) } |
| 38 | + |
| 39 | + override int getArchiveParameterIndex() { result = 0 } |
| 40 | +} |
| 41 | + |
| 42 | +/** |
| 43 | + * The `mz_zip_reader_open_file` and `mz_zip_reader_open_file_in_memory` functions as a flow step. |
| 44 | + */ |
| 45 | +class ReaderOpenFunctionStep extends DecompressionFlowStep { |
| 46 | + ReaderOpenFunctionStep() { this = "ReaderOpenFunctionStep" } |
| 47 | + |
| 48 | + override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { |
| 49 | + exists(FunctionCall fc | |
| 50 | + fc.getTarget().hasGlobalName(["mz_zip_reader_open_file_in_memory", "mz_zip_reader_open_file"]) |
| 51 | + | |
| 52 | + node1.asIndirectExpr() = fc.getArgument(1) and |
| 53 | + node2.asIndirectExpr() = fc.getArgument(0) |
| 54 | + ) |
| 55 | + } |
| 56 | +} |
0 commit comments