File: 141-segfault-on-accept.lua

package info (click to toggle)
lua-cqueues 20161214-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,672 kB
  • ctags: 3,228
  • sloc: ansic: 20,232; sh: 2,959; makefile: 24
file content (27 lines) | stat: -rwxr-xr-x 712 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
_=[[
	. "${0%%/*}/regress.sh"
	exec runlua "$0" "$@"
]]
--
-- Issue #141 -- Lua/C accept method binding doesn't check whether the
-- socket has already been closed, passing a NULL socket object to low-level
-- so_accept routine. Fix was to use the lso_checkself utility routine like
-- every other method, which will throw an error when passed a closed
-- socket.
--
require"regress".export".*"

info"opening listening socket"
local con = socket.listen("localhost", 0)

info"calling close"
con:close();

-- bug caused NULL dereference in so_clear, invoked from lso_accept
info"calling accept"
local ok = pcall(con.accept, con, 0);
check(not ok, "con:accept didn't throw error as expected")

say("OK")