summaryrefslogtreecommitdiffstats
path: root/reg-tests/lua/wrong_types_usage.vtc
blob: ed76579ba2d7e4671fe71bb14d027dfc01abe308 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# commit f874a83
# BUG/MINOR: lua: Segfaults with wrong usage of types.
#
# Patrick reported that this simple configuration made haproxy segfaults:
#
#     global
#         lua-load /tmp/haproxy.lua
#
#     frontend f1
#         mode http
#         bind :8000
#         default_backend b1
#
#         http-request lua.foo
#
#     backend b1
#         mode http
#         server s1 127.0.0.1:8080
#
# with this '/tmp/haproxy.lua' script:
#
#     core.register_action("foo", { "http-req" }, function(txn)
#         txn.sc:ipmask(txn.f:src(), 24, 112)
#     end)
#
# This is due to missing initialization of the array of arguments
# passed to hlua_lua2arg_check() which makes it enter code with
# corrupted arguments.
#
# Thanks a lot to Patrick Hemmer for having reported this issue.


varnishtest "Basic LUA test h00000"
#REQUIRE_OPTIONS=LUA
#REGTEST_TYPE=bug

feature ignore_unknown_macro

server s1 -repeat 2 {
    rxreq
    txresp
} -start

haproxy h1 -conf {
    global
        lua-load ${testdir}/wrong_types_usage.lua

    frontend fe1
        mode http
        bind "fd@${fe1}"
        default_backend b1

        http-request lua.foo

    backend b1
        mode http
        server s1 ${s1_addr}:${s1_port}

} -start

client c0 -connect ${h1_fe1_sock} {
    txreq -url "/foo"
    rxresp
    expect resp.status == 200
}

client c1 -connect ${h1_fe1_sock} {
    txreq -url "/foo"
    rxresp
    expect resp.status == 200
}

client c0 -start
client c1 -start

client c0 -wait
client c1 -wait