Bug 44824 - [PATCH] Infinite loop in hwpf/usermodel/Picture.java
[PATCH] Infinite loop in hwpf/usermodel/Picture.java
Product: POI
Classification: Unclassified
Component: HWPF
All All
: P2 normal (vote)
: ---
Assigned To: POI Developers List
: PatchAvailable
Depends on:
  Show dependency tree
Reported: 2008-04-14 19:24 UTC by Mike Flester
Modified: 2008-05-20 08:47 UTC (History)
1 user (show)

patch for infinite loop in Picture.java (694 bytes, patch)
2008-04-27 12:53 UTC, Mike Flester
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Flester 2008-04-14 19:24:47 UTC
hwpf/usermodel/Picture.java has an infinite loop in getting the JPEG height and
width. This patch fixes the loop to not be infinite. The infinite loop is not 
normally triggered, only when the first byte of the image is not as expected.
Comment 1 Nick Burch 2008-04-27 11:05:18 UTC
There doesn't seem to be any patch associated with this bug :(

Any chance you could upload the patch, and also a .doc file that shows up the problem? That way, we can knock up a unit test for this too, and make sure we don't break it again in the future
Comment 2 Mike Flester 2008-04-27 12:53:50 UTC
Created attachment 21860 [details]
patch for infinite loop in Picture.java

Sorry about the missing patch, thought I had uploaded it before but I guess not.
The only document I have to demonstrate this is proprietary content, but 
hopefully once you see the one line patch you'll agree that it is an easy call.
Comment 3 Nick Burch 2008-05-20 08:47:57 UTC
I've updated Picture.java to skip on two bytes at a time, until it finds what it wants. This should avoid the loop.

However, there's no unit test for this, so it might potentially get broken again in the future. So, if you do find a file that triggers this, which you can upload for us to test against, that'd be great!