From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97529C04AAA for ; Mon, 6 May 2019 08:42:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AA59205C9 for ; Mon, 6 May 2019 08:42:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="LzTCcbml"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="LzTCcbml" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbfEFImN (ORCPT ); Mon, 6 May 2019 04:42:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47102 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbfEFImM (ORCPT ); Mon, 6 May 2019 04:42:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EBB7C61157; Mon, 6 May 2019 08:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1557132131; bh=U0HcKzTKhMJAx+L7DrntSHVJn8Uwl4RoExSSOsr90rA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=LzTCcbmlUE/ubC1rumbvwkOkGg9dENA5ms3hX24F4AERKl+o2w31ByGKHjn+ThRR8 k63Wj6bH5YHf6NwNs3ROVFYkxG7NAOLS/NtFBrHwvI/98L+N2o66LTVRUjQfHhRFZY /plx+IcESnNDnrK+rTBBF+yxCTajnFEFmcNxXASc= Received: from x230.qca.qualcomm.com (37-136-65-53.rev.dnainternet.fi [37.136.65.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 92E1B60DB3; Mon, 6 May 2019 08:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1557132131; bh=U0HcKzTKhMJAx+L7DrntSHVJn8Uwl4RoExSSOsr90rA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=LzTCcbmlUE/ubC1rumbvwkOkGg9dENA5ms3hX24F4AERKl+o2w31ByGKHjn+ThRR8 k63Wj6bH5YHf6NwNs3ROVFYkxG7NAOLS/NtFBrHwvI/98L+N2o66LTVRUjQfHhRFZY /plx+IcESnNDnrK+rTBBF+yxCTajnFEFmcNxXASc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 92E1B60DB3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Hans de Goede Cc: Victor Bravo <1905@spmblk.com>, Arend Van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , "David S. Miller" , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC] brcmfmac: sanitize DMI strings v2 References: <20190504162633.ldrz2nqfocg55grb@localhost> <20190504194440.4zcxjrtj2aft3ka4@localhost> <16a87149068.2764.9b12b7fc0a3841636cfb5e919b41b954@broadcom.com> <20190505150355.3fbng4ny34x255vk@localhost> <0f75a3d4-94af-5503-94c3-e8af2364448d@redhat.com> Date: Mon, 06 May 2019 11:42:06 +0300 In-Reply-To: <0f75a3d4-94af-5503-94c3-e8af2364448d@redhat.com> (Hans de Goede's message of "Mon, 6 May 2019 10:13:38 +0200") Message-ID: <87o94gug81.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hans de Goede writes: >> @@ -99,6 +107,15 @@ static const struct dmi_system_id dmi_platform_data[] = { >> {} >> }; >> +void brcmf_dmi_sanitize(char *dst, const unsigned char *allowed, >> char safe) >> +{ >> + while (*dst) { >> + if ((*dst < 0) || !(allowed[*dst / 8] & (1 << (*dst % 8)))) > > At a first look I have no clue what this code is doing and I honestly do not feel > like figuring it out, this is clever, but IMHO not readable. > > Please just write this as if (*dst < 0x21 || (*dst > foo && < bar) || etc, > so that a human can actually see in one look what the code is doing. Is there an existing function for sanitising filenames so that we don't need to reinvent the wheel, maybe something like isalnum()? -- Kalle Valo