Bug #10535
closedPotential uninitialized reference pipe_open() in io.c
Description
(From git commit f5063b7ea7e774519602f7a112d9acf536a1da33 of 22 November 2014.)
In io.c in the following function:
IF !defined(HAVE_WORKING_FORK) and !defined(HAVE_SPAWNV), THEN argc and argv are declared. (lines 5938, 5939)
Unless I'm missing something in the #if #else #endif fiesta, they don't seem to be initialized anywhere.
Then in the #else case at line 6069, we have this:
#else
if (argc) {
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
cmd = StringValueCStr(prog);
}
Best case, the compiler initializes argc to 0, which means this is dead code. Worst case, the compiler chooses not to initialize to 0, then Bad Things will happen.
Updated by normalperson (Eric Wong) almost 11 years ago
asmaloney@gmail.com wrote:
IF !defined(HAVE_WORKING_FORK) and !defined(HAVE_SPAWNV), THEN argc
and argv are declared. (lines 5938, 5939)
Unless I'm missing something in the #if #else #endif fiesta, they
don't seem to be initialized anywhere.
I concur. On the other hand, which platforms are affected by this
problem? Any platform maintainers care to comment? Maybe we can
drop the code :)
A side note: we'd be better off reimplementing pipe_open (and similar
functions) individually on a per-platform basis to avoid the ugly
CPP conditionals.
Right now, it's hard-to-read for every platform. Of course, this split
requires much coordination between platform maintainers...
Updated by jeremyevans0 (Jeremy Evans) over 6 years ago
- Status changed from Open to Closed
I believe this issue was fixed by aa107497cd379b713eba8cecdb9a882bb1e0dd89, which removed the argc and argv variables in favor of using rb_execarg_commandline(eargp, &prog), and eargp and prog are always initialized.