Project

General

Profile

Actions

Bug #7423

closed

ruby_process_options() dereferences argv even if argc is zero

Added by gfim (Graham Menhennitt) almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]
Backport:
[ruby-core:49889]

Description

In ruby_process_options(), there is a line:

ruby_script(argv[0]);  /* for the time being */

This dereferences argv whether argc is zero or not. This causes a SEGV if there are no command line args. It should be changed to something like:

ruby_script(argc == 0 ? "ruby" : argv[0]);

In practice, this is unlikely to happen since shells never pass argc as zero. However, it can happen in two situations:

  • a program calls something like 'static char argv[] = {0}; execv("/usr/bin/ruby", argv);'
  • somebody embedding a ruby interpreter explicitly calls ruby_process_options(0, 0);

Argv is used in a number of other places too. These should all be tested for zero arguments.

Actions

Also available in: Atom PDF

Like0
Like0Like0