From fd1047ae6eaf5fba472dfb484e7465438196a93c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 10 May 2023 17:46:10 +0200 Subject: [PATCH] DEV: flags/show-sess-to-flags: only retrieve hex digits from hex fields Some fields are followed by a comma or a closing parenthesis and we take them because we read everything that's not a space. Better be stricter, we're causing warnings about incorrect hex format when they're passed to printf. --- dev/flags/show-sess-to-flags.sh | 62 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/dev/flags/show-sess-to-flags.sh b/dev/flags/show-sess-to-flags.sh index d81efc2d8..73e5f9698 100755 --- a/dev/flags/show-sess-to-flags.sh +++ b/dev/flags/show-sess-to-flags.sh @@ -133,46 +133,46 @@ while read -r; do fi if [ $ctx = strm ]; then - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag strm.flg strm "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag strm.flg strm "${BASH_REMATCH[1]}" elif [ $ctx = task ]; then - ! [[ "$REPLY" =~ \(state=([^[:blank:]]*) ]] || append_flag task.state task "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ \(state=([0-9a-fx]*) ]] || append_flag task.state task "${BASH_REMATCH[1]}" elif [ $ctx = txn ]; then ! [[ "$REPLY" =~ [[:blank:]]meth=([^[:blank:]]*) ]] || append_str txn.meth "${BASH_REMATCH[1]}" "${HTTP_METH[$((${BASH_REMATCH[1]}))]}" - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag txn.flg txn "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]req\.f=([^[:blank:]]*) ]] || append_flag txn.req.flg hmsg "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]rsp\.f=([^[:blank:]]*) ]] || append_flag txn.rsp.flg hmsg "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag txn.flg txn "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]req\.f=([0-9a-fx]*) ]] || append_flag txn.req.flg hmsg "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]rsp\.f=([0-9a-fx]*) ]] || append_flag txn.rsp.flg hmsg "${BASH_REMATCH[1]}" elif [ $ctx = scf ]; then - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag f.sc.flg sc "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]endp=[[:alnum:]]*,[[:alnum:]]*,([^[:blank:]]*) ]] || append_flag f.sc.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1s.*\.sd\.flg=([^[:blank:]]*) ]] || append_flag f.h1s.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1s\.flg=([^[:blank:]]*) ]] || append_flag f.h1s.flg h1s "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1c\.flg=([^[:blank:]]*) ]] || append_flag f.h1c.flg h1c "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ ^[[:blank:]]*\.sc=.*\.flg=.*\.app=.*\.sd=[^=]*\.flg=([^[:blank:]]*) ]] || append_flag f.h2s.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h2s.*\.flg=([^[:blank:]]*) ]] || append_flag f.h2s.flg h2s "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h2c.*\.flg=([^[:blank:]]*) ]] || append_flag f.h2c.flg h2c "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag f.sc.flg sc "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]endp=[[:alnum:]]*,[[:alnum:]]*,([0-9a-fx]*) ]] || append_flag f.sc.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1s.*\.sd\.flg=([0-9a-fx]*) ]] || append_flag f.h1s.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1s\.flg=([0-9a-fx]*) ]] || append_flag f.h1s.flg h1s "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1c\.flg=([0-9a-fx]*) ]] || append_flag f.h1c.flg h1c "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ ^[[:blank:]]*\.sc=.*\.flg=.*\.app=.*\.sd=[^=]*\.flg=([0-9a-fx]*) ]] || append_flag f.h2s.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h2s.*\.flg=([0-9a-fx]*) ]] || append_flag f.h2s.flg h2s "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h2c.*\.flg=([0-9a-fx]*) ]] || append_flag f.h2c.flg h2c "${BASH_REMATCH[1]}" elif [ $ctx = cof ]; then - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag f.co.flg conn "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]fd.state=([^[:blank:]]*) ]] || append_flag f.co.fd.st fd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag f.co.flg conn "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]fd.state=([0-9a-fx]*) ]] || append_flag f.co.fd.st fd "${BASH_REMATCH[1]}" elif [ $ctx = req ]; then - ! [[ "$REPLY" =~ [[:blank:]]\(f=([^[:blank:]]*) ]] || append_flag req.flg chn "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]an=([^[:blank:]]*) ]] || append_flag req.ana ana "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]htx.*flags=([^[:blank:]]*) ]] || append_flag req.htx.flg htx "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]\(f=([0-9a-fx]*) ]] || append_flag req.flg chn "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]an=([0-9a-fx]*) ]] || append_flag req.ana ana "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]htx.*flags=([0-9a-fx]*) ]] || append_flag req.htx.flg htx "${BASH_REMATCH[1]}" elif [ $ctx = scb ]; then - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag b.sc.flg sc "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]endp=[[:alnum:]]*,[[:alnum:]]*,([^[:blank:]]*) ]] || append_flag b.sc.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1s.*\.sd\.flg=([^[:blank:]]*) ]] || append_flag b.h1s.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1s\.flg=([^[:blank:]]*) ]] || append_flag b.h1s.flg h1s "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h1c\.flg=([^[:blank:]]*) ]] || append_flag b.h1c.flg h1c "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ ^[[:blank:]]*\.sc=.*\.flg=.*\.app=.*\.sd=[^=]*\.flg=([^[:blank:]]*) ]] || append_flag b.h2s.sd.flg sd "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h2s.*\.flg=([^[:blank:]]*) ]] || append_flag b.h2s.flg h2s "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]h2c.*\.flg=([^[:blank:]]*) ]] || append_flag b.h2c.flg h2c "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag b.sc.flg sc "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]endp=[[:alnum:]]*,[[:alnum:]]*,([0-9a-fx]*) ]] || append_flag b.sc.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1s.*\.sd\.flg=([0-9a-fx]*) ]] || append_flag b.h1s.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1s\.flg=([0-9a-fx]*) ]] || append_flag b.h1s.flg h1s "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h1c\.flg=([0-9a-fx]*) ]] || append_flag b.h1c.flg h1c "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ ^[[:blank:]]*\.sc=.*\.flg=.*\.app=.*\.sd=[^=]*\.flg=([0-9a-fx]*) ]] || append_flag b.h2s.sd.flg sd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h2s.*\.flg=([0-9a-fx]*) ]] || append_flag b.h2s.flg h2s "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]h2c.*\.flg=([0-9a-fx]*) ]] || append_flag b.h2c.flg h2c "${BASH_REMATCH[1]}" elif [ $ctx = cob ]; then - ! [[ "$REPLY" =~ [[:blank:]]flags=([^[:blank:]]*) ]] || append_flag b.co.flg conn "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]fd.state=([^[:blank:]]*) ]] || append_flag b.co.fd.st fd "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]flags=([0-9a-fx]*) ]] || append_flag b.co.flg conn "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]fd.state=([0-9a-fx]*) ]] || append_flag b.co.fd.st fd "${BASH_REMATCH[1]}" elif [ $ctx = res ]; then - ! [[ "$REPLY" =~ [[:blank:]]\(f=([^[:blank:]]*) ]] || append_flag res.flg chn "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]an=([^[:blank:]]*) ]] || append_flag res.ana ana "${BASH_REMATCH[1]}" - ! [[ "$REPLY" =~ [[:blank:]]htx.*flags=([^[:blank:]]*) ]] || append_flag res.htx.flg htx "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]\(f=([0-9a-fx]*) ]] || append_flag res.flg chn "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]an=([0-9a-fx]*) ]] || append_flag res.ana ana "${BASH_REMATCH[1]}" + ! [[ "$REPLY" =~ [[:blank:]]htx.*flags=([0-9a-fx]*) ]] || append_flag res.htx.flg htx "${BASH_REMATCH[1]}" fi out[${#out[@]}]="$REPLY"