From ccac3a32670132a4019b003c687b2d370068bd11 Mon Sep 17 00:00:00 2001 From: Dino Korah <691011+codemedic@users.noreply.github.com> Date: Sun, 22 Mar 2026 21:47:08 +0000 Subject: [PATCH] fix: escape socket path regex metacharacters in pgrep fallback --- quickemu | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quickemu b/quickemu index cde805f..52d4da1 100755 --- a/quickemu +++ b/quickemu @@ -1685,8 +1685,10 @@ function start_virtiofsd() { if command -v fuser >/dev/null 2>&1; then VIRTIOFSD_PID=$(fuser "${VIRTIOFSD_SOCKET}" 2>/dev/null | tr -s ' ' '\n' | grep -m1 '[0-9]') else - local candidate - candidate=$(pgrep -f "virtiofsd.*${VIRTIOFSD_SOCKET}" 2>/dev/null | head -1) + local candidate socket_pat + # Escape regex metacharacters in the socket path before passing to pgrep -f. + socket_pat=$(printf '%s' "${VIRTIOFSD_SOCKET}" | sed 's/[[\.*^$()+?{}|]/\\&/g') + candidate=$(pgrep -f "virtiofsd.*${socket_pat}" 2>/dev/null | head -1) if ps -p "${candidate}" -o comm= 2>/dev/null | grep -q 'virtiofsd'; then VIRTIOFSD_PID="${candidate}" fi