Bug 440551
Summary: | file -k behaviour broken since 4.4 | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 4 | Reporter: | Bryan Mason <nobody+bjmason> | ||||||
Component: | file | Assignee: | Daniel Novotny <dnovotny> | ||||||
Status: | CLOSED ERRATA | QA Contact: | |||||||
Severity: | high | Docs Contact: | |||||||
Priority: | high | ||||||||
Version: | 4.6 | CC: | bmason, ksrot, rvokal, tao | ||||||
Target Milestone: | rc | Keywords: | Regression | ||||||
Target Release: | --- | ||||||||
Hardware: | All | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2009-05-18 20:06:09 UTC | Type: | --- | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Bug Depends On: | |||||||||
Bug Blocks: | 391511 | ||||||||
Attachments: |
|
Description
Bryan Mason
2008-04-03 23:02:38 UTC
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 |