blob: 577329eb3070b520135ca9369045ca555afa8028 [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
Christopher Faulet8f161482018-12-19 11:49:39 +010049 ${no-htx} option http-use-htx
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020050 bind "fd@${fe1}"
51 default_backend b1
52
53 http-request lua.foo
54
55 backend b1
56 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010057 ${no-htx} option http-use-htx
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020058 server s1 ${s1_addr}:${s1_port}
59
60} -start
61
62client c0 -connect ${h1_fe1_sock} {
63 txreq -url "/foo"
64 rxresp
65 expect resp.status == 200
66}
67
68client c1 -connect ${h1_fe1_sock} {
69 txreq -url "/foo"
70 rxresp
71 expect resp.status == 200
72}
73
74client c0 -start
75client c1 -start
76
77client c0 -wait
78client c1 -wait