Project

General

Profile

Actions

Bug #9157

closed

rb_readlink() calls rb_str_modify_expand() too early

Added by nowacki (Maciek Nowacki) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 2.0.0p353 (2013-11-22) [x86_64-linux]
[ruby-core:58592]

Description

If rb_readlink() (file.c) is called on a long symlink, Ruby tends to crash. This is present in -trunk. The problem is that the rb_str_modify_expand() statement is incorrectly placed before the statement 'size*=2'. Here is a patch:

--- - 2013-11-25 22:10:59.694183795 -0700
+++ file.c 2013-11-25 22:10:03.076352889 -0700
@@ -2529,8 +2529,8 @@
|| (rv < 0 && errno == ERANGE) /* quirky behavior of GPFS */
#endif
) {

  • rb_str_modify_expand(v, size);
    size *= 2;
  • rb_str_modify_expand(v, size);
    }
    if (rv < 0) {
    rb_str_resize(v, 0);

Files

file.c.patch (310 Bytes) file.c.patch nowacki (Maciek Nowacki), 11/26/2013 03:12 PM

Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Bug #9158: bug in rb_readlink() in file.c (fixed)ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0