Project

General

Profile

Actions

Bug #4338

closed

random number generator not reseeded after fork in 1.8

Added by normalperson (Eric Wong) about 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
[ruby-core:34944]

Description

=begin
rand should return different values in forked processes like in 1.9.2. This
may have security implications for some programs.

Remembering to call srand after forking will fix the issue, but remembering is
hard especially since 1.9.2 makes it easy :)

The following example prints out 3 identical lines in 1.8.7:

fork { $stdout.syswrite("#{rand}\n") }
fork { $stdout.syswrite("#{rand}\n") }
$stdout.syswrite("#{rand}\n")
Process.waitall
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0