Summary: | Use-After-Free in i_free_object() | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Kamil Frankowicz <kamil.frankowicz> |
Component: | General | Assignee: | Default assignee <ghostpdl-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P4 | ||
Version: | master | ||
Hardware: | PC | ||
OS: | Linux | ||
Customer: | Word Size: | --- | |
Attachments: | POC to trigger use-after-free (gs) |
Description
Kamil Frankowicz
2017-02-20 00:58:35 UTC
There is confusion over ownership of 'penum' between gx_begin_image1(), gx_begin_image4() and gx_image_enum_begin() which is called form these two functions. The enumerator is allocated in gx_begin_image?() and freed there if gx_image_enum_begin() returns an error, which is I believe the correct course. However, gx_image_enum_begin() also frees the enumerator on an error, except that it doesn't always do so. Its a large function and there are at least 9 ways to exit it, only 4 of which free the enumerator. Since gx_image_enum_begin() didn't allocate the memory I feel it should not free it either. My proposal for this is to remove the cases in here where the enumerator memory is freed. Fixed in commit ecceafe3abba2714ef9b432035fe0739d9b1a283 Thanks for the report, very well spotted! |