After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 667745 - icon cache can be unsafe when accessing missing icons
icon cache can be unsafe when accessing missing icons
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-01-12 11:16 UTC by Will Newton
Modified: 2012-01-26 03:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the issue (944 bytes, patch)
2012-01-12 11:16 UTC, Will Newton
accepted-commit_now Details | Review
iconcache: Always check return value of find_image_offset. (995 bytes, patch)
2012-01-26 03:59 UTC, Matthias Clasen
committed Details | Review

Description Will Newton 2012-01-12 11:16:59 UTC
Created attachment 205073 [details] [review]
Patch to fix the issue

The icon cache code can make some bad memory accesses when an icon that is not present in the builtin cache is requested.

The function find_image_offset will return the offset of an image or 0 if it cannot be found. The return value of this function should be checked for 0 to see whether or not the offset is a valid one. Of the 3 call sites of this function 2 check the return value but the other, in _gtk_icon_cache_get_icon, does not.

The attached patch adds a check on the return value of find_image_offset. On a system with only the builtin icon cache this prevents the icon cache code doing erroneous memory accesses when an icon that is not present is requested.
Comment 1 Matthias Clasen 2012-01-15 19:28:37 UTC
Review of attachment 205073 [details] [review]:

Good catch, thanks
Comment 2 Matthias Clasen 2012-01-26 03:59:14 UTC
The following fix has been pushed:
96cfd3f iconcache: Always check return value of find_image_offset.
Comment 3 Matthias Clasen 2012-01-26 03:59:17 UTC
Created attachment 206150 [details] [review]
iconcache: Always check return value of find_image_offset.

find_image_offset returns 0 if it failed to find a matching image.
Check this return value in _gtk_icon_cache_get_icon to avoid
making bad memory accesses later.

Signed-off-by: Will Newton <will.newton@imgtec.com>