Closed Bug 84523 Opened 24 years ago Closed 24 years ago

Corrupted GIF hangs Mozilla

Categories

(Core :: Graphics: ImageLib, defect, P1)

x86
All
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: dv5a, Assigned: nivedita)

Details

(Keywords: hang)

Attachments

(2 files)

Some corrupted GIFs images hangs Mozilla I will upload a testcase
Severity: normal → critical
Keywords: hang
Summary: Corrupted GIF Image Hangs Mozilla → Corrupted GIF hangs Mozilla
Confirming, OS: win2K, Build: win32-talkback 2001060620. OS: Linux, Build: linux-sea 2001060620 Changing OS to ALL. Mozilla also starts to consume all the cpu when hung.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows NT → All
->saari
Assignee: pavlov → saari
Also seems to hang Netscape 4.x, and an image reader app that I wrote. Wow.
I've taken a look at this GIF. The problem is that after the normal header, there is a bad datablock. If you're scanning through the GIF for a terminating code, you have to skip the datablock by reading all the run lengths from it. The run lengths total more than the size of the GIF itself. At this point, you'll probably never find the terminating code. Saari, I apologize for the horrible terminology. I haven't looked at the source for libpr0n itself, so I don't know what everything's called in the source. But basically, wherever you scan for the terminate code, if you add a check to make sure the pointer hasn't passed the end of the image, it should fix the hang.
Cool, thanks for the description of the problem!
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.3
Target Milestone: mozilla0.9.3 → mozilla0.9.4
P1 for 0.9.4
Priority: -- → P1
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Target Milestone: mozilla0.9.7 → mozilla0.9.8
over to nivedita
Assignee: saari → nivedita
Status: ASSIGNED → NEW
Target Milestone: mozilla0.9.8 → ---
The reason for mozilla hanging in the given test case, was because the gif in the given test case has an netscape extension code of 4, while the valid extension codes as per gif specs are 1 and 2, hence we were handling only the cases of 1 and 2. Since the other cases were not handled, the next state of gif was not being set causing it to remain in the same state, resulting mozilla to hang.
Comment on attachment 65743 [details] [diff] [review] patch file fixing the mozilla hang in case of invalid netscape extension codes in the gif r=pavlov
Attachment #65743 - Flags: review+
Would it be better to attempt skipping the block "GETN(*q, gif_skip_block)"?
I don't think so. You don't know the size of the block that you need to skip, since the extention is bogus. IE doesn't load the image and actually hangs Windows Imaging.
Actually this is one thing the GIF spec got right - all blocks have a block size byte as their first entry. From the spec: 13. Block Sizes. The Block Size field in a block, counts the number of bytes remaining in the block, not counting the Block Size field itself, and not counting the Block Terminator, if one is to follow. Blocks other than Data Blocks are intended to be of fixed length; the Block Size field is provided in order to facilitate skipping them, not to allow their size to change in the future. Data blocks and sub-blocks are of variable length to accommodate the amount of data.
Comment on attachment 65743 [details] [diff] [review] patch file fixing the mozilla hang in case of invalid netscape extension codes in the gif sr=tor
Attachment #65743 - Flags: superreview+
checked in fix.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified Fixed Win XP build 2002012903, Linux build 2002012909 and Mac OS X build 2002012808
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: