From nobody Tue Apr 7 07:08:25 2026 Received: from sender-of-o57.zoho.eu (sender-of-o57.zoho.eu [136.143.169.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54575374E48 for ; Sun, 15 Mar 2026 17:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773594675; cv=pass; b=doVphkghODwgT/pwyWj9yXwLSXnG8gaUgeu0/0bGSvE/Wie9xcu2mSP2YoiyFD9Cwmjmurl66qOfuTO/icF5gxsjd1xN+eyubvmlAZcDmwWT3ZdBgIEaxmQsOwn7yOPqcgLCBsBcSyVNB3vnlVskRS4hINT1i/KXLMRkDXIaQzA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773594675; c=relaxed/simple; bh=TvoodWqX4Zt9qaZn8/cmtP96TLJg6Fl3uNkMx+/OM/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ceTnXadeFeFcIbopZhI+Zp25zk3xTHc7xZzojLnXBQJJTqdLqoOIfrBo3rSNb3c1Cu2WtDng7MCxWBZ1tIrIZhENi7nFybSIZHCC3kVQlIVMYVwrcVNeew8SCRxp1zUXJho+XUTh6TXzP/QzWYR7SfGC4oA9DKLx1xoSQcfjhlk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=Rac2q6iY; arc=pass smtp.client-ip=136.143.169.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="Rac2q6iY" ARC-Seal: i=1; a=rsa-sha256; t=1773594669; cv=none; d=zohomail.eu; s=zohoarc; b=dR3F2p/X9N9tWcQ0qmfoic/u4I3le+VZffInZyyNm9EZ8TdDXBI83bpbcpWKwIJl+bKBo2b8JR7Cc9mmdhF5WgdHjNMzHoxlPDavfWN0UHX3FWkqEpmMwUhdKJwFmvPZ5PFK+e62XbKV5gASyz8GUy/aIBoARhIOWQ12nQKoWEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773594669; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=IKJGSUF4neu8mf6CKhF1x8j3j8JrAeeYnr9Wq9xiqSo=; b=BHSGgq9Etwmd4NjzovwMqoR52Nn2a9KyGd0L+rGMgQ3hl8zJCGPvQNJ11mUKU9oZGYloPZkZIaNUoyAZOSHEykEi3Rhyy2L1mSDSqIV+w98E+9grEBN6IgA4WEMz2v/7yIEb1vkusANCE6ByIlFB3c6s4k3hblBwsjue1uDDVtM= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773594669; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=IKJGSUF4neu8mf6CKhF1x8j3j8JrAeeYnr9Wq9xiqSo=; b=Rac2q6iYNXMtjtm4wMWwMQVkZsCdEaX+KQB/TsdCiv6dBWP6PJS3dUMQ2uRtH3+f ikAzRViPeknvyt5RER6uUZgu9sL1FT7t1o6K6p6/k2EkMfbWMlszfXeheKhDygdo+yy VFDfdGHpq0ftDtJiDbBa/uROsnVlbyb8td+oZc4M= Received: by mx.zoho.eu with SMTPS id 1773594667152528.1242515151395; Sun, 15 Mar 2026 18:11:07 +0100 (CET) From: Josh Law To: Andrew Morton , Josh Law Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/7] lib/glob: normalize inverted character class ranges Date: Sun, 15 Mar 2026 17:10:58 +0000 Message-Id: <20260315171104.268944-2-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315171104.268944-1-objecting@objecting.org> References: <20260315171104.268944-1-objecting@objecting.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" When a character class range has its endpoints reversed (e.g., [z-a]), the comparison a <=3D c && c <=3D b can never be true, so the range silently matches nothing. A pattern like "file[9-0]" intended to match any digit would fail to match anything, with no indication that the range is backwards. Swap the endpoints when a > b so that inverted ranges behave the same as their forward equivalents: [z-a] matches the same characters as [a-z], and [9-0] matches the same as [0-9]. This is consistent with how GNU fnmatch and other glob implementations handle reversed ranges. Signed-off-by: Josh Law --- lib/glob.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/glob.c b/lib/glob.c index 7aca76c25bcb..cb45a9a47f28 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -94,7 +94,13 @@ bool __pure glob_match(char const *pat, char const *str) goto literal; =20 class +=3D 2; - /* Any special action if a > b? */ + /* Normalize inverted ranges like [z-a] */ + if (a > b) { + unsigned char tmp =3D a; + + a =3D b; + b =3D tmp; + } } if (a <=3D c && c <=3D b) match =3D true; --=20 2.34.1