Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop in src/imagew-jpeg.c: my_skip_input_data_fn #26

Closed
oddcoder opened this issue May 13, 2017 · 1 comment
Closed

infinite loop in src/imagew-jpeg.c: my_skip_input_data_fn #26

oddcoder opened this issue May 13, 2017 · 1 comment

Comments

@oddcoder
Copy link

oddcoder commented May 13, 2017

Done via fuzzed JPEG on master
1

my_skip_input_data_fn tries to skip 0x8000 bytes which is bigger than the file size thus leading to infinite loop trying to reread from the buffer
I believe if reading failed there isn't too much that can be done to save the situation
this is my suggested edit

diff --git a/src/imagew-jpeg.c b/src/imagew-jpeg.c
index 43bf946..e0cbf2a 100644
--- a/src/imagew-jpeg.c
+++ b/src/imagew-jpeg.c
@@ -333,6 +333,9 @@ static void my_skip_input_data_fn(j_decompress_ptr cinfo, long num_bytes)
 
                rctx->pub.next_input_byte = rctx->buffer;
                rctx->pub.bytes_in_buffer = bytesread;
+               if (bytesread == 0) {
+                       return;
+               }
        }
 }
@oddcoder oddcoder changed the title logical bug in src/imagew-jpeg.c: my_skip_input_data_fn that leads to infinite loop infinite loop in src/imagew-jpeg.c: my_skip_input_data_fn May 13, 2017
jsummers added a commit that referenced this issue May 15, 2017
This fixes a bug that could cause an infinite loop.
It also corrects some error messages from "improper call to jpeg library"
to e.g. "unexpected end of file".
Fixes issue #26
@jsummers
Copy link
Owner

Should be fixed by commit 62bfbfb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants