From afd5f5d671d52f2a5a1fb9df9d05bf29f90859b0 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 8 Apr 2025 17:36:49 +0200 Subject: [PATCH] DEV: h2: fix h2-tracer.lua nil value index Nick Ramirez reported the following error while testing the h2-tracer.lua script: Lua filter 'h2-tracer' : [state-id 0] runtime error: /etc/haproxy/h2-tracer.lua:227: attempt to index a nil value (field '?') from /etc/haproxy/h2-tracer.lua:227: in function line 109. It is caused by h2ff indexing with an out of bound value. Indeed, h2ff is indexed with the frame type, which can potentially be > 9 (not common nor observed during Willy's tests), while h2ff only defines indexes from 0 to 9. The fix was provided by Willy, it consists in skipping h2ff indexing if frame type is > 9. It was confirmed that doing so fixes the error. --- dev/h2/h2-tracer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/h2/h2-tracer.lua b/dev/h2/h2-tracer.lua index 71643bb62..b31ee15f2 100644 --- a/dev/h2/h2-tracer.lua +++ b/dev/h2/h2-tracer.lua @@ -224,7 +224,7 @@ function Dec:tcp_payload(txn, chn) ff = "" for i = 7, 0, -1 do if (((self.st[dir].fflg >> i) & 1) ~= 0) then - if h2ff[self.st[dir].ftyp][i] ~= nil then + if self.st[dir].ftyp <= 9 and h2ff[self.st[dir].ftyp][i] ~= nil then ff = ff .. ((ff == "") and "" or "+") ff = ff .. h2ff[self.st[dir].ftyp][i] else