blob: 321ddf47b6cf01226d739a64eed7ce8792b97a9a [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
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +010035#REGTEST_TYPE=bug
Christopher Fauletfdafd9a2018-12-19 11:50:17 +010036
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020037feature ignore_unknown_macro
38
39server s1 -repeat 2 {
40 rxreq
41 txresp
42} -start
43
44haproxy h1 -conf {
45 global
Frédéric Lécailleb894f922019-03-29 16:13:48 +010046 lua-load ${testdir}/wrong_types_usage.lua
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020047
48 frontend fe1
49 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010050 ${no-htx} option http-use-htx
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020051 bind "fd@${fe1}"
52 default_backend b1
53
54 http-request lua.foo
55
56 backend b1
57 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010058 ${no-htx} option http-use-htx
Frédéric Lécaille153b2b62018-06-18 19:32:10 +020059 server s1 ${s1_addr}:${s1_port}
60
61} -start
62
63client c0 -connect ${h1_fe1_sock} {
64 txreq -url "/foo"
65 rxresp
66 expect resp.status == 200
67}
68
69client c1 -connect ${h1_fe1_sock} {
70 txreq -url "/foo"
71 rxresp
72 expect resp.status == 200
73}
74
75client c0 -start
76client c1 -start
77
78client c0 -wait
79client c1 -wait