Detect and reject profiles which we would walk off the end

The linked example is a 3 channel 2x2x2 table that happens to have
nothing after it.

I considered several fixes, but the fact that skcms really doesn't
want to own buffers or do any allocation makes that tricky.

Given that moxcms will be doing the parsing in Chromium and
https://review.skia.org/1215162 will make sure there's sufficient
padding, we'll make skcms's own parsing be a bit pickier such
that the buffer is big enough for a 1-2 byte overread.

Clients can allocate their buffer up to the next multiple of 4
bytes (on 32 bit systems) or 8 bytes (on 64 bit sytems) to make
sure there's plenty of padding.

None of the existing tests fail locally on xsan (the bug was
only on 32 bit anyway).

Bug: oss-fuzz:504261818
Change-Id: I8f1206b993c427e13e38038ef7abde6f651732a4
Reviewed-on: https://skia-review.googlesource.com/c/skcms/+/1214462
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Kaylee Lubick <kjlubick@google.com>
4 files changed
tree: 28c151c2bc2e9bbfd41e1b419061923edfe68925
  1. bazel/
  2. fuzz/
  3. infra/
  4. ninja/
  5. profiles/
  6. src/
  7. toolchain/
  8. .bazelrc
  9. .bazelversion
  10. .gitignore
  11. BAZEL.md
  12. bench.c
  13. BUILD.bazel
  14. build.ninja
  15. codereview.settings
  16. iccdump.c
  17. LICENSE
  18. MODULE.bazel
  19. MODULE.bazel.lock
  20. msvs.ninja
  21. OWNERS
  22. README.chromium
  23. README.md
  24. skcms.cc
  25. skcms.gni
  26. skcms.h
  27. test_only.c
  28. test_only.h
  29. tests.c
  30. whitespace.txt
README.md

To build with ninja, simply run ninja from the root directory. This will produce a library in /out.

There are also Bazel rules, outlined in BAZEL.md