From 9c138ff62ce14d1a1417a31e932858b2a5db2c72 Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Wed, 5 Mar 2025 16:05:30 +1300 Subject: [PATCH 1/2] Fix panic when prediction calculation is invalid --- src/parser.rs | 6 ++++++ .../images/invalid-prediction-shift.jpg | Bin 0 -> 3860 bytes 2 files changed, 6 insertions(+) create mode 100644 tests/crashtest/images/invalid-prediction-shift.jpg diff --git a/src/parser.rs b/src/parser.rs index 5b4dffe1..b17e7e9a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -405,6 +405,12 @@ pub fn parse_sos(reader: &mut R, frame: &FrameInfo) -> Result let predictor_selection; let point_transform = successive_approximation_low; + if point_transform >= frame.precision { + return Err(Error::Format( + "invalid point transform, must be less than the frame precision".to_owned(), + )); + } + if frame.coding_process == CodingProcess::DctProgressive { predictor_selection = Predictor::NoPrediction; if spectral_selection_end > 63 || spectral_selection_start > spectral_selection_end || diff --git a/tests/crashtest/images/invalid-prediction-shift.jpg b/tests/crashtest/images/invalid-prediction-shift.jpg new file mode 100644 index 0000000000000000000000000000000000000000..386f63ebc83b7aae9e206a4fb34e5a1e6db0117b GIT binary patch literal 3860 zcmex=_tv~ScdSO@@1n*bPl Yl%{J4y#M`gv?oQ^5QkYN|NkZf0E&em(f|Me literal 0 HcmV?d00001 From 00d6bd912dd0ec2eda9e9c867341c321787740dc Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Wed, 5 Mar 2025 17:00:44 +1300 Subject: [PATCH 2/2] Use Ubuntu 22.04 in CI --- .github/workflows/rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb988981..6a3a7aae 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: @@ -39,7 +39,7 @@ jobs: FEATURES: ${{ matrix.features }} cross_compile_aarch64: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: @@ -71,7 +71,7 @@ jobs: FEATURES: ${{ matrix.features }} CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc cross_compile_wasm: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Install node run: |