From nobody Fri Apr 17 21:55:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1775978331; cv=none; d=zohomail.com; s=zohoarc; b=HbOdfWa6OkVQ6XbILW5UQ78ZW73O8cuXtibBq6dnde/sZLg5XiCnMWsftXKYG0VyqZjdR4zQEFrjWMoQCsh3dq5jzOeuJfI7z5AsNvaGE9Sg0y/lUHHP0BNAz1Cele/XerwkB6AEhBQkJ7PEvpyHzz5zcgpYiXPVlAMUj5fZQBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775978331; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BLW0aiBjBbC6HZ0ymGnT0MvW6yhUqayPJbrrEehtO/8=; b=I9SN2Nz8R0vLd4oLdWdDpDaaRrmfKruxQ2FlgR6oqHtS+o7l1N0Z2lluqO89vaNVrK58zfL9q+qWgZLDxU/ZFfMSwXjI0KQtUCD19dIzoB5X7w0NXtotriZ5luVcjPW9s1ITlqjjTEuq7tCBNNDWrrrz8KpDP4lw7hzszYy2LVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775978328592564.4853341728991; Sun, 12 Apr 2026 00:18:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wBp5C-0007ZQ-1x; Sun, 12 Apr 2026 03:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wBp59-0007Z7-2l; Sun, 12 Apr 2026 03:18:11 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wBp56-00057T-9q; Sun, 12 Apr 2026 03:18:10 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3039A19D611; Sun, 12 Apr 2026 10:17:09 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id E3306394611; Sun, 12 Apr 2026 10:18:03 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1775978229; bh=Ii6uLQ7SVYIqmQDuAU/zlm75kkuTaU3xz0u4cZXiKP4=; h=From:To:Cc:Subject:Date; b=ncI27t+UjP2SvbTvtN9hZQpigYdeg31Kj9UWSMltbEWEJjOZfwkiqDrKLKTQtf+6Z BAy0p6bkcByG8NUcUP3xJU8ou9XtixvImGpG3Rpw8XFHCy8vvIO2dWTkz74n3+Vc5W KMmkJ+X/w/wT7ABSuw9TU5Jqa6480y5Lx1CIxEIW92Ax4CQ0x6G2qpaMVfJ4de1Z8J YiYjZpAq8pfXYK80WELosiluEi25k8R2kjYbgniLG3rMW5W7YbmPaIOghk9CPchV8J 6rlZrBPVE6vNN0GXVJqTYjQihEcdwW9WXJ8n7AxrsjAl0y6QhLhtvMwCqXm3MPkrVo PU0IVTN6TzVkg== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: Michael Tokarev , qemu-trivial@nongnu.org, Christopher Palmer-Richez Subject: [PATCH trivial v3] net/slirp: allow hostfwd socket paths with dashes Date: Sun, 12 Apr 2026 10:17:49 +0300 Message-ID: <20260412071754.569575-1-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1775978341816154100 Content-Type: text/plain; charset="utf-8" The format of hostfwd parameter is: hostfwd=3Dhostpart-guestaddr:guestport so a minus sign can not be part of the hostpart. If hostpart specifies a unix socket path, this becomes problematic. To solve this, look for the LAST minus/dash char in the string, not first. Unfortunately, [-guestaddr] is optional (defaults to 10.0.0.15), so we still can't parse the thing in an uniform way. Extend get_str_sep() to accept negative separator to indicate searching from the end of buffer, to find the last occurence. Update slirp_hostfwd to search for the last separator when parsing unix domain socket path. Inspired-by: Christopher Palmer-Richez Resolves: https://gitlab.com/qemu-project/qemu/-/issues/347 Signed-off-by: Michael Tokarev --- v3: instead of adding an additional argument to get_str_sep() and changing all callers, (ab)use signedness of the separator. net/slirp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index 04925f3318..847e7dab63 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -54,7 +54,8 @@ static int get_str_sep(char *buf, int buf_size, const cha= r **pp, int sep) const char *p, *p1; int len; p =3D *pp; - p1 =3D strchr(p, sep); + /* negative sep means to search -sep from the end of buf */ + p1 =3D sep >=3D 0 ? strchr(p, sep) : strrchr(p, -sep); if (!p1) return -1; len =3D p1 - p; @@ -848,7 +849,7 @@ static int slirp_hostfwd(SlirpState *s, const char *red= ir_str, Error **errp) =20 #if !defined(WIN32) && SLIRP_CHECK_VERSION(4, 7, 0) if (is_unix) { - if (get_str_sep(buf, sizeof(buf), &p, '-') < 0) { + if (get_str_sep(buf, sizeof(buf), &p, 0 - '-') < 0) { fail_reason =3D "Missing - separator"; goto fail_syntax; } --=20 2.47.3