Skip to content

Conversation

trigger-segfault
Copy link

Multiple corrections to img_jpg unpacking in HG-3 images.

Changes

  • Switched RGB channel order during pixels copy: "img_jpg" tag format unpack operation was swapping RGB -> BGR when already in BGR format.
  • Removed second null-terminator in ASCII equals check: "img_al" tag name had two null-terminator checks. And apparently... CatSystem 2 does not guarantee anything after the first null-terminator in a fixed-length string (yikes). This can be observed with a few assets in the cs2_full_v301 toolset:
    • be01S_0000001.hg3: 69 6D 67 5F 61 6C 00 B5 : "img_al.5""
    • Note, however, that most img_al tags will have a clean two null bytes in the tag name, this seems to only be an infrequent issue.

* `"img_jpg"` tag format unpack operation was swapping RGB -> BGR when already in BGR format.
* `"img_al"` tag name had two null-terminator checks. And apparently CatSystem 2 does not guarantee anything after the first null-terminator in a fixed-length string *(yikes)*. This can be observed with a few assets in the `cs2_full_v301` toolset, like `be01S_0000001.hg3`: `69 6D 67 5F 61 6C 00 B5` : `"img_al.5"`
@trigger-segfault trigger-segfault changed the title (HG3): fix img_jpg RGB swapping and img_al null-terminator check (HG3): fix img_jpg RGB swapping and img_al null-terminator check. May 19, 2021
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