lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

The IO library's popen function passes its second parameter, if given,
unmodified to either POSIX popen() or MSVC _popen(). In the first
case, any value except "r" and "w" is explicitly documented to cause
undefined behavior. In the second case, more values are permitted, and
nothing is said about the behavior when other values are used, which
normally means again undefined behavior.

I have seen that io.popen("foo", "r+") crashes the host at least with
some versions of MSVC on some versions of Windows. I do not think it
is correct that a function callable from Lua should be able to cause
the C language undefined behavior, so I'd say the IO library should
not allow arbitrary arguments for the mode parameter.

That was found in Lua 5.3, and looking at the code on Github, will
apply to Lua 5.4.