Skip to content

[FIX] Use RL16/RL32/RL64 for multi-byte values in asf_functions.c and general_loop.c - #2401

Open
muntasir-396 wants to merge 1 commit into
CCExtractor:masterfrom
muntasir-396:fix/asf-use-rl-macros
Open

muntasir-396 wants to merge 1 commit into
CCExtractor:masterfrom
muntasir-396:fix/asf-use-rl-macros

Conversation

@muntasir-396

Copy link
Copy Markdown

Summary

Follow-up to #2353 and #2364, which eliminated unaligned multi-byte pointer casting across utility.h, mp4.c, ts_tables.c, and ccx_gxf.c.

In src/lib_ccx/asf_functions.c and src/lib_ccx/general_loop.c, multi-byte values were still read by casting arbitrary byte pointers to uint16_t *, uint32_t *, or int64_t * and dereferencing them. This is undefined behavior under C11 6.3.2.3p7 (missing alignment guarantee) and breaks on big-endian architectures (ASF and RCWT headers are little-endian).

Changes

  1. src/lib_ccx/utility.h: Added RL64 and RB64 macros matching the byte-wise pattern of RL16/RL32 and RB16/RB32.
  2. src/lib_ccx/asf_functions.c: Replaced all unaligned pointer casts with RL16, RL32, and RL64 throughout ASF header, stream property, content description, and data packet parsing.
  3. src/lib_ccx/general_loop.c: Replaced direct pointer casts when reading the 10-byte RCWT data header (FTS and cbcount) with RL64 and RL16.

… general_loop.c

Follow-up to CCExtractor#2353 and CCExtractor#2364, which eliminated unaligned multi-byte
pointer casting across utility.h, mp4.c, ts_tables.c, and ccx_gxf.c.

In asf_functions.c and general_loop.c, multi-byte values were read by
casting arbitrary byte buffers to uint16_t *, uint32_t *, or int64_t *
and dereferencing them. This is undefined behavior under C11 6.3.2.3p7
due to missing alignment guarantees, and breaks on big-endian platforms
(ASF and RCWT header fields are little-endian).

This patch:
- Adds byte-wise RL64 and RB64 definitions to utility.h.
- Replaces unaligned multi-byte pointer casts in asf_functions.c with
  RL16, RL32, and RL64.
- Replaces unaligned multi-byte reads of RCWT headers in general_loop.c
  with RL64 and RL16.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant