Skip to content

Commit c264e0d

Browse files
committed
fix: update lz4 pattern for android
Add pattern to detect lz4 version in Android libraries where the version string format differs from standard Linux binaries. - Add FILENAME_PATTERNS to match liblz4 library files - Add VERSION_PATTERN to match Android format where version appears between ERROR_* strings (works across API 30 and API 34) - Add test cases for Android lz4 format (API 30: 1.8.3, API 34: 1.9.4) Partial fix for #5441
1 parent b605e46 commit c264e0d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cve_bin_tool/checkers/lz4.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
class Lz4Checker(Checker):
1818
CONTAINS_PATTERNS: list[str] = []
19-
FILENAME_PATTERNS: list[str] = []
19+
FILENAME_PATTERNS: list[str] = [r"liblz4"]
2020
VERSION_PATTERNS = [
2121
r"lz4-([0-9]+\.[0-9]+\.[0-9]+)",
2222
r"([0-9]+\.[0-9]+\.[0-9]+)\r?\nUnspecified error code\r?\nOK_NoError",
23+
r"ERROR_[a-zA-Z_]+[\x00\s]+([0-9]+\.[0-9]+\.[0-9]+)[\x00\s]+ERROR_[a-zA-Z_]+",
2324
]
2425
VENDOR_PRODUCT = [("lz4_project", "lz4"), ("yann_collet", "lz4")]

test/test_data/lz4.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
"version": "1.9.3",
99
"version_strings": ["1.9.3\nUnspecified error code\nOK_NoError"],
1010
},
11+
{
12+
"product": "lz4",
13+
"version": "1.8.3",
14+
"version_strings": ["ERROR_srcPtr_wrong\x001.8.3\x00ERROR_frameType_unknown"],
15+
},
16+
{
17+
"product": "lz4",
18+
"version": "1.9.4",
19+
"version_strings": ["ERROR_parameter_null\x001.9.4\x00ERROR_blockMode_invalid"],
20+
},
1121
]
1222
package_test_data = [
1323
{

0 commit comments

Comments
 (0)