Commit 34b29f3
authored
fix: broken pgm having memory access error (#4559)
Fixes #4552
Caught during fuzzing with address sanitizer.
The source of the problem was a corrupted/truncated pgm file. Several
minor modifications in this PR shore up various cascading errors that
followed. Not all were directly causal to the sanitizer trigger, in some
cases I fixed what appeared to be related areas.
* In imagebuf.cpp, any time we free the local pixel memory m_pixels,
also explicitly clear the m_bufspan that has a span representation of
the usable memory and its bounds.
* An extra check related to oiiotool --printstats to make sure that the
image is valid before passing along to stats collection.
* In pnminput.cpp, a better error message when we hit a premature end of
file.
With these fixes in place, we seem to get a graceful error message and
exit when running the POC that was provided with the bug report.
Signed-off-by: Larry Gritz <[email protected]>1 parent 78927ac commit 34b29f3
File tree
6 files changed
+26
-3
lines changed- src
- libOpenImageIO
- oiiotool
- pnm.imageio
- testsuite/pnm
- ref
- src
6 files changed
+26
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| 690 | + | |
690 | 691 | | |
691 | 692 | | |
692 | 693 | | |
| |||
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
| 724 | + | |
| 725 | + | |
723 | 726 | | |
724 | 727 | | |
725 | 728 | | |
| |||
806 | 809 | | |
807 | 810 | | |
808 | 811 | | |
| 812 | + | |
809 | 813 | | |
810 | 814 | | |
811 | 815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5801 | 5801 | | |
5802 | 5802 | | |
5803 | 5803 | | |
5804 | | - | |
| 5804 | + | |
| 5805 | + | |
5805 | 5806 | | |
5806 | 5807 | | |
5807 | 5808 | | |
| |||
5818 | 5819 | | |
5819 | 5820 | | |
5820 | 5821 | | |
| 5822 | + | |
5821 | 5823 | | |
5822 | 5824 | | |
5823 | 5825 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
| 227 | + | |
227 | 228 | | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
72 | 83 | | |
73 | 84 | | |
74 | 85 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments