aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-15 16:01:03 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-15 16:01:03 -0300
commit1ecfbfa1a1debd2258decdf7c1954ac6f9761699 (patch)
treea03e232e5c6a6c9cf6b4fe7b5b31d73a614ad26a /testes
parente1d8770f12542d34a3e32b825c95b93f8a341ee1 (diff)
downloadlua-1ecfbfa1a1debd2258decdf7c1954ac6f9761699.tar.gz
lua-1ecfbfa1a1debd2258decdf7c1954ac6f9761699.tar.bz2
lua-1ecfbfa1a1debd2258decdf7c1954ac6f9761699.zip
Fixed bug: invalid mode can crash 'io.popen'
Diffstat (limited to 'testes')
-rw-r--r--testes/files.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/testes/files.lua b/testes/files.lua
index 677c0dc2..16cf9b6a 100644
--- a/testes/files.lua
+++ b/testes/files.lua
@@ -721,6 +721,21 @@ if not _port then
721 progname = '"' .. arg[i + 1] .. '"' 721 progname = '"' .. arg[i + 1] .. '"'
722 end 722 end
723 print("testing popen/pclose and execute") 723 print("testing popen/pclose and execute")
724 -- invalid mode for popen
725 checkerr("invalid mode", io.popen, "cat", "")
726 checkerr("invalid mode", io.popen, "cat", "r+")
727 checkerr("invalid mode", io.popen, "cat", "rw")
728 do -- basic tests for popen
729 local file = os.tmpname()
730 local f = assert(io.popen("cat - > " .. file, "w"))
731 f:write("a line")
732 assert(f:close())
733 local f = assert(io.popen("cat - < " .. file, "r"))
734 assert(f:read("a") == "a line")
735 assert(f:close())
736 assert(os.remove(file))
737 end
738
724 local tests = { 739 local tests = {
725 -- command, what, code 740 -- command, what, code
726 {"ls > /dev/null", "ok"}, 741 {"ls > /dev/null", "ok"},