diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-13 00:59:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-13 00:59:00 +0000 |
commit | 6434617d50f08b7e360870757b613c3069504085 (patch) | |
tree | 25f27e2a51292179c9b3f198803ecf7c1b6018cc /ruby.c | |
parent | c8fba35bd5a7fedf15c404a9398161d166f96a03 (diff) |
* ruby.c (ruby_init_loadpath): ensures buffer terminated
before use strncpy().
* ruby.c (proc_options): avoid SEGV at -S with no arguments.
(ruby-bugs-ja:PR#391)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@3489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -233,6 +233,7 @@ ruby_init_loadpath() #define CharNext(p) ((p) + 1) #endif + libpath[FILENAME_MAX] = '\0'; for (p = libpath; *p; p = CharNext(p)) if (*p == '\\') *p = '/'; @@ -675,14 +676,14 @@ proc_options(argc, argv) OBJ_TAINT(rb_load_path); } - if (!e_script && argc == 0) { /* no more args */ - if (verbose) exit(0); - script = "-"; - } - else { + if (argc == 0) { /* no more args */ if (!e_script) { - script = argv[0]; + if (verbose) exit(0); + script = "-"; } + } + else if (!e_script) { + script = argv[0]; if (script[0] == '\0') { script = "-"; } @@ -700,9 +701,7 @@ proc_options(argc, argv) if (!script) script = argv[0]; } } - if (!e_script) { - argc--; argv++; - } + argc--; argv++; } ruby_script(script); |