Forum: Ruby-core [Closed] bug in rb_readlink() in file.c (fixed)

F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-11-30 05:43
(Received via mailing list)
Issue #9158 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Closed
ruby -v set to trunk


----------------------------------------
Bug #9158:  bug in rb_readlink() in file.c (fixed)
https://bugs.ruby-lang.org/issues/9158#change-43277

Author: nowacki (Maciek Nowacki)
Status: Closed
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


 Hello,

 Here is a cute bug that has existed for a little while in file.c . Ruby
will tend to crash when File.readlink() is called on a symlink with a
long target. Fix:

 --- -  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);

 Maciek Nowacki
 Application Support Analyst
 Information Services & Technology
 University of Alberta
This topic is locked and can not be replied to.