Bug 435631
Summary: | ruby recurses indefinitely when cwd is broken and path empty | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 5 | Reporter: | Andrew Hecox <ahecox> | ||||||
Component: | ruby | Assignee: | Vít Ondruch <vondruch> | ||||||
Status: | CLOSED ERRATA | QA Contact: | QE Internationalization Bugs <qe-i18n-bugs> | ||||||
Severity: | medium | Docs Contact: | |||||||
Priority: | urgent | ||||||||
Version: | 5.1 | CC: | bkabrda, rdassen, rkhadgar, tao | ||||||
Target Milestone: | rc | Keywords: | Patch | ||||||
Target Release: | --- | ||||||||
Hardware: | All | ||||||||
OS: | Linux | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||
Doc Text: | Story Points: | --- | |||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2012-02-21 06:00:29 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: | 668957, 719046 | ||||||||
Attachments: |
|
Description
Andrew Hecox
2008-03-02 19:01:16 UTC
The following patch presents one way of fixing the recursion problem by raising a rb_eRuntimeError if the relative path built in path_check_0 grows beyond MAXPATHLEN (eg, 4096). While not specifically targeting the case of a broken cwd, it seems a reasonable check to perform under all conditions. Another option would be to backport 1.8.6's non-recursive implementation of path_check_0; I did not do this because it relied on a series of macros defined in 1.8.6 not present in our version. However, that seems another reasonable and simple solution. I also fixed some white-space in the effected conditional block. Created attachment 296521 [details]
check maxpathlen patch
Created attachment 301632 [details]
ruby getcwd path based on upstream code.
This request was evaluated by Red Hat Product Management for inclusion, but this component is not scheduled to be updated in the current Red Hat Enterprise Linux release. If you would like this request to be reviewed for the next minor release, ask your support representative to set the next rhel-x.y flag to "?". This request was evaluated by Red Hat Product Management for inclusion, but this component is not scheduled to be updated in the current Red Hat Enterprise Linux release. If you would like this request to be reviewed for the next minor release, ask your support representative to set the next rhel-x.y flag to "?". This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unfortunately unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux. This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unfortunately unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux. I have been investigating this problem and it seems, that the patch in comment 3 by ritz is ok. I have reproduced the bug and the problem is, that if you do the steps from comment 1: sudo mount <nfs>:<export> /mnt/ cd /mnt/foo sudo umount -l /mnt/ PATH= then my_getcwd() function used to get the current working directory returns only 'foo/' (if you 'cd /mnt/foo/bar' instead of just 'cd /mnt/foo', my_getcwd returns 'foo/bar'). So when you call the function for the first time, it finds out that the path is not absolute (because its empty, thats why the 'PATH=' has to be present), so it calls my_getcwd and before recursing, it has "newpath = 'foo/'". This is not absolute path, so in the next call, the function prepends another 'foo/' to newpath. Therefore the recursion never ends, constructing the newpath in form of 'foo/foo/foo/foo/...', which is never absolute. The patch works because my_getcwd uses getcwd (which returns an absolute path in a normal case), so in a normal case, the recursion is not needed anyway. In the special case mentioned in comment 1, getcwd returns just foo/ and path_check_0 continues (and works) normally. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0218.html |