The code assumes that read and write will read and write according to their
specified third argument.
I haven't written C in over 10 years, but I believe that not handling
properly the return value of read and write is a bug.
So
} else if ((s == (CHUNK_SIZE + SPARE_SIZE))) {
} else {
fprintf(stderr, "broken image file\n");
is probably wrong. The image file isn't broken. The reading just didn't
read enough characters and
if (write(out_file, chunk_data, s) == -1)
return -1;
remain -= s;
1. assumes we read s characters,
2. doesn't consider if some characters weren't written.
The attached patch also contains
* the --help option has found in issue #3 (patch is improved as we don't
used strncmp otherwise we match --helpWHATEVER_COMES_AFTER
* a new --verbose option
* a tentative fix for this potential issue
Original issue reported on code.google.com by jerome.l...@gmail.com on 4 May 2009 at 11:56
Original issue reported on code.google.com by
jerome.l...@gmail.com
on 4 May 2009 at 11:56Attachments: