blob: 5d396a75cd84201867740838ef8c2d110f421c8c [file] [log] [blame]
Frédéric Lécaille153b2b62018-06-18 19:32:10 +02001# commit f874a83
2# BUG/MINOR: lua: Segfaults with wrong usage of types.
3#
4# Patrick reported that this simple configuration made haproxy segfaults:
5#
6# global
7# lua-load /tmp/haproxy.lua
8#
9# frontend f1
10# mode http
11# bind :8000
12# default_backend b1
13#
14# http-request lua.foo
15#
16# backend b1
17# mode http
18# server s1 127.0.0.1:8080
19#
20# with this '/tmp/haproxy.lua' script:
21#
22# core.register_action("foo", { "http-req" }, function(txn)
23# txn.sc:ipmask(txn.f:src(), 24, 112)
24# end)
25#
26# This is due to missing initialization of the array of arguments
27# passed to hlua_lua2arg_check() which makes it enter code with
28# corrupted arguments.
29#
30# Thanks a lot to Patrick Hemmer for having reported this issue.
31
32
33varnishtest "Basic LUA test h00000"
Christopher Fauletfdafd9a2018-12-19 11:50:17 +010034#REQUIRE_OPTIONS=LUA
35
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020036feature ignore_unknown_macro
37
38server s1 -repeat 2 {
39 rxreq
40 txresp
41} -start
42
43haproxy h1 -conf {
44 global
Frédéric Lécaille99316342018-08-22 10:41:33 +020045 lua-load ${testdir}/b00000.lua
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020046
47 frontend fe1
48 mode http
49 bind "fd@${fe1}"
50 default_backend b1
51
52 http-request lua.foo
53
54 backend b1
55 mode http
56 server s1 ${s1_addr}:${s1_port}
57
58} -start
59
60client c0 -connect ${h1_fe1_sock} {
61 txreq -url "/foo"
62 rxresp
63 expect resp.status == 200
64}
65
66client c1 -connect ${h1_fe1_sock} {
67 txreq -url "/foo"
68 rxresp
69 expect resp.status == 200
70}
71
72client c0 -start
73client c1 -start
74
75client c0 -wait
76client c1 -wait