Skip to content

Commit 2f6595c

Browse files
committed
* 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/trunk@3489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 168f2f4 commit 2f6595c

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Thu Feb 13 09:58:12 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
2+
3+
* ruby.c (ruby_init_loadpath): ensures buffer terminated
4+
before use strncpy().
5+
6+
* ruby.c (proc_options): avoid SEGV at -S with no arguments.
7+
(ruby-bugs-ja:PR#391)
8+
19
Thu Feb 13 01:30:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
210

311
* eval.c (rb_thread_schedule): current thread may be dead when

ruby.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ ruby_init_loadpath()
255255
_execname(libpath, FILENAME_MAX);
256256
#endif
257257

258+
libpath[FILENAME_MAX] = '\0';
258259
#ifdef DOSISH
259260
translate_char(libpath, '\\', '/');
260261
#endif
@@ -704,14 +705,14 @@ proc_options(argc, argv)
704705
OBJ_TAINT(rb_load_path);
705706
}
706707

707-
if (!e_script && argc == 0) { /* no more args */
708-
if (verbose) exit(0);
709-
script = "-";
710-
}
711-
else {
708+
if (argc == 0) { /* no more args */
712709
if (!e_script) {
713-
script = argv[0];
710+
if (verbose) exit(0);
711+
script = "-";
714712
}
713+
}
714+
else if (!e_script) {
715+
script = argv[0];
715716
if (script[0] == '\0') {
716717
script = "-";
717718
}
@@ -728,13 +729,11 @@ proc_options(argc, argv)
728729
}
729730
if (!script) script = argv[0];
730731
}
731-
}
732-
if (!e_script) {
733-
argc--; argv++;
734-
}
735732
#ifdef DOSISH
736-
translate_char(script, '\\', '/');
733+
translate_char(script, '\\', '/');
737734
#endif
735+
}
736+
argc--; argv++;
738737
}
739738

740739
ruby_script(script);

0 commit comments

Comments
 (0)