From a0e0ae75576ec92be8c6436a2d7180d944f9fb02 Mon Sep 17 00:00:00 2001
From: Plato Mavropoulos <platomav@users.noreply.github.com>
Date: Thu, 3 Apr 2025 00:14:35 +0300
Subject: [PATCH] BIOSUtilities v25.04.02

Improved UAF module detection at AMI UCP Extract
Fixed crashes at Dell PFS and Award BIOS Extract
Upgraded dependency "dissect.util" to 3.20
---
 CHANGELOG                           | 6 ++++++
 README.md                           | 4 ++--
 biosutilities/__init__.py           | 2 +-
 biosutilities/ami_ucp_extract.py    | 5 ++++-
 biosutilities/award_bios_extract.py | 4 ++--
 biosutilities/dell_pfs_extract.py   | 6 +++---
 pyproject.toml                      | 2 +-
 requirements-dev.txt                | 2 +-
 requirements.txt                    | 2 +-
 9 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 87e69fd..4ccdd4b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+25.04.02
+
+Improved UAF module detection at AMI UCP Extract
+Fixed crashes at Dell PFS and Award BIOS Extract
+Upgraded dependency "dissect.util" to 3.20
+
 25.02.23
 
 Fixed AMI PFAT Extract file naming of "ALL" and "OOB"
diff --git a/README.md b/README.md
index f243715..bc98fb7 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ There are two main types of requirements, depending on the utility: "Python Pack
 #### Python Packages
 
 * [pefile](https://pypi.org/project/pefile/2023.2.7/)
-* [dissect.util](https://pypi.org/project/dissect.util/3.19/)
+* [dissect.util](https://pypi.org/project/dissect.util/3.20/)
 
 Python packages can be installed via Pypi (e.g. pip)
 
@@ -37,7 +37,7 @@ python -m pip install --upgrade -r requirements.txt
 or
 
 ``` bash
-python -m pip install pefile==2023.2.7 dissect.util==3.19
+python -m pip install pefile==2023.2.7 dissect.util==3.20
 ```
 
 #### External Executables / Scripts
diff --git a/biosutilities/__init__.py b/biosutilities/__init__.py
index e6c4a95..8696292 100644
--- a/biosutilities/__init__.py
+++ b/biosutilities/__init__.py
@@ -5,4 +5,4 @@
 Copyright (C) 2018-2025 Plato Mavropoulos
 """
 
-__version__ = '25.02.23'
+__version__ = '25.04.02'
diff --git a/biosutilities/ami_ucp_extract.py b/biosutilities/ami_ucp_extract.py
index 144b5e5..c0614cc 100644
--- a/biosutilities/ami_ucp_extract.py
+++ b/biosutilities/ami_ucp_extract.py
@@ -4,7 +4,7 @@
 """
 AMI UCP Extract
 AMI UCP Update Extractor
-Copyright (C) 2021-2024 Plato Mavropoulos
+Copyright (C) 2021-2025 Plato Mavropoulos
 """
 
 import contextlib
@@ -341,6 +341,9 @@ class AmiUcpExtract(BIOSUtility):
 
             uaf_mod_len: int = uaf_hdr.ModuleSize
 
+            if uaf_mod_len < 0x400:
+                continue
+
             uaf_mod_dat: bytes = uaf_mod_buf[:uaf_mod_len]
 
             if uaf_mod_len != len(uaf_mod_dat):
diff --git a/biosutilities/award_bios_extract.py b/biosutilities/award_bios_extract.py
index 9ebda11..8068728 100644
--- a/biosutilities/award_bios_extract.py
+++ b/biosutilities/award_bios_extract.py
@@ -4,7 +4,7 @@
 """
 Award BIOS Extract
 Award BIOS Module Extractor
-Copyright (C) 2018-2024 Plato Mavropoulos
+Copyright (C) 2018-2025 Plato Mavropoulos
 """
 
 import os
@@ -52,7 +52,7 @@ class AwardBiosExtract(BIOSUtility):
 
                 continue
 
-            if len(mod_bin) >= 0x16:
+            if len(mod_bin) > 0x16:
                 tag_txt: str = safe_name(in_name=mod_bin[0x16:0x16 + mod_bin[0x15]].decode('utf-8', 'ignore').strip())
             else:
                 tag_txt = f'{mod_bgn:X}_{mod_end:X}'
diff --git a/biosutilities/dell_pfs_extract.py b/biosutilities/dell_pfs_extract.py
index 2854a7b..387c92f 100644
--- a/biosutilities/dell_pfs_extract.py
+++ b/biosutilities/dell_pfs_extract.py
@@ -4,7 +4,7 @@
 """
 Dell PFS Extract
 Dell PFS Update Extractor
-Copyright (C) 2018-2024 Plato Mavropoulos
+Copyright (C) 2018-2025 Plato Mavropoulos
 """
 
 import contextlib
@@ -431,7 +431,7 @@ class DellPfsExtract(BIOSUtility):
         header_data: bytes = zlib_data[header_start:compressed_start]
 
         # Check if the PFS ZLIB section header Checksum XOR 8 is valid
-        if checksum_8_xor(data=header_data[:0xF]) != header_data[0xF]:
+        if len(header_data) > 0xF and checksum_8_xor(data=header_data[:0xF]) != header_data[0xF]:
             printer(message='Error: Invalid Dell PFS ZLIB section Header Checksum!', padding=padding)
 
             is_zlib_error = True
@@ -461,7 +461,7 @@ class DellPfsExtract(BIOSUtility):
             is_zlib_error = True
 
         # Check if the PFS ZLIB section footer Checksum XOR 8 is valid
-        if checksum_8_xor(data=footer_data[:0xF]) != footer_data[0xF]:
+        if len(footer_data) > 0xF and checksum_8_xor(data=footer_data[:0xF]) != footer_data[0xF]:
             printer(message='Error: Invalid Dell PFS ZLIB section Footer Checksum!', padding=padding)
 
             is_zlib_error = True
diff --git a/pyproject.toml b/pyproject.toml
index 5536ca5..002e6ed 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -34,7 +34,7 @@ classifiers = [
 ]
 
 [project.optional-dependencies]
-lznt1 = ["dissect.util == 3.19"]
+lznt1 = ["dissect.util == 3.20"]
 pefile = ["pefile == 2023.2.7"]
 
 [project.urls]
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 103fdc2..82f122b 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,2 +1,2 @@
 mypy==1.15.0
-pylint==3.3.4
+pylint==3.3.6
diff --git a/requirements.txt b/requirements.txt
index 36429ce..c590269 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-dissect.util==3.19
+dissect.util==3.20
 pefile==2023.2.7