Description of problem: Running "file -k <file.tgz>" doesn't emit extra output. Version-Release number of selected component (if applicable): file-4.10-3.0.2.el4.i386 How reproducible: Always. Steps to Reproduce: 1. Download attached file, for example. 2. file -k /path/to/broken-file.tgz Actual results: /tmp/broken-file.tgz: FLI file - 18355 frames, width=768 pixels, height=15852 pixels, depth=30717, ticks/frame=64434\012 Expected results: /tmp/broken-file.tgz: FLI file - 18355 frames, width=768 pixels, height=15852 pixels, depth=30717, ticks/frame=64434\012- gzip compressed data, from Unix Additional info: Proposed patch will be attached.
Created attachment 300362 [details] Example test file.
Created attachment 300363 [details] Proposed patch.
This is actually a regression induced by the fix to Bug 174348. The important bit of code in the patch that fixed that bug is here: while (n > 0) { bytesconsumed = mbrtowc(&nextchar, op, n, &state); if (bytesconsumed == (size_t)(-1) || bytesconsumed == (size_t)(-2)) { mb_conv = 0; break; } if (iswprint (nextchar) ){ memcpy (np, op, bytesconsumed); op += bytesconsumed; } else { *np++ = '\\'; *np++ = ((*op >> 6) & 3) + '0'; *np++ = ((*op >> 3) & 7) + '0'; *np++ = ((*op >> 0) & 7) + '0'; op++; } np += bytesconsumed; n -= bytesconsumed; } *np = '\0'; np is getting double-incremented whenever the loop comes across a non-printable character. It gets incremented during the conversion of the non-printable character to it's octal representation: } else { *np++ = '\\'; *np++ = ((*op >> 6) & 3) + '0'; *np++ = ((*op >> 3) & 7) + '0'; *np++ = ((*op >> 0) & 7) + '0'; op++; } and then again at the bottom of the loop: np += bytesconsumed; Since np gets incremented twice, an uninitialized value (which I supposed happens to be zero most of the time) gets left in the buffer, truncating the buffer when it gets printed. The proposed patch moves "np += bytesconsumed" inside "if (iswprint (nextchar) ){"
This bugzilla has Keywords: Regression. Since no regressions are allowed between releases, it is also being proposed as a blocker for this release. Please resolve ASAP.
the patch works, thanks. we can use it in the next release.
fixed in file-4.10-6.el4
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2009-0954.html