Frédéric Lécaille | 153b2b6 | 2018-06-18 19:32:10 +0200 | [diff] [blame] | 1 | # 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 | |
| 33 | varnishtest "Basic LUA test h00000" |
| 34 | feature ignore_unknown_macro |
| 35 | |
| 36 | server s1 -repeat 2 { |
| 37 | rxreq |
| 38 | txresp |
| 39 | } -start |
| 40 | |
| 41 | haproxy h1 -conf { |
| 42 | global |
Frédéric Lécaille | 9931634 | 2018-08-22 10:41:33 +0200 | [diff] [blame^] | 43 | lua-load ${testdir}/b00000.lua |
Frédéric Lécaille | 153b2b6 | 2018-06-18 19:32:10 +0200 | [diff] [blame] | 44 | |
| 45 | frontend fe1 |
| 46 | mode http |
| 47 | bind "fd@${fe1}" |
| 48 | default_backend b1 |
| 49 | |
| 50 | http-request lua.foo |
| 51 | |
| 52 | backend b1 |
| 53 | mode http |
| 54 | server s1 ${s1_addr}:${s1_port} |
| 55 | |
| 56 | } -start |
| 57 | |
| 58 | client c0 -connect ${h1_fe1_sock} { |
| 59 | txreq -url "/foo" |
| 60 | rxresp |
| 61 | expect resp.status == 200 |
| 62 | } |
| 63 | |
| 64 | client c1 -connect ${h1_fe1_sock} { |
| 65 | txreq -url "/foo" |
| 66 | rxresp |
| 67 | expect resp.status == 200 |
| 68 | } |
| 69 | |
| 70 | client c0 -start |
| 71 | client c1 -start |
| 72 | |
| 73 | client c0 -wait |
| 74 | client c1 -wait |