From: Kalle Valo <kvalo@codeaurora.org>
To: Victor Bravo <1905@spmblk.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Arend Van Spriel <arend.vanspriel@broadcom.com>,
Franky Lin <franky.lin@broadcom.com>,
Hante Meuleman <hante.meuleman@broadcom.com>,
Chi-Hsien Lin <chi-hsien.lin@cypress.com>,
Wright Feng <wright.feng@cypress.com>,
"David S. Miller" <davem@davemloft.net>,
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
Date: Mon, 06 May 2019 15:29:21 +0300 [thread overview]
Message-ID: <878svjvk9q.fsf@codeaurora.org> (raw)
In-Reply-To: <20190506091441.wqtccm4n6xxhxom2@localhost> (Victor Bravo's message of "Mon, 6 May 2019 11:14:41 +0200")
Victor Bravo <1905@spmblk.com> writes:
> On Mon, May 06, 2019 at 11:42:06AM +0300, Kalle Valo wrote:
>> Hans de Goede <hdegoede@redhat.com> 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()?
>
> I would definitely prefer to use existing function, but I didn't find
> any suitable one. Suggestions are welcome.
I didn't find anything either, but hopefully someone knows.
> As for implementation details, the one I posted was optimized for both
> speed and size, and at least in my opinion this bit array driven
> parametric implementation is exactly what is needed here (using a string
> of allowed characters with strchr-style lookups would bring much worse
> complexity, and checking the characters using series of hardcoded if
> conditions could quickly grow to more than those 16 bytes used by the
> array).
But is this really something which should be optimised? This is driver
initialisation, not in some hot path, right? Can you even measure the
difference?
--
Kalle Valo
next prev parent reply other threads:[~2019-05-06 12:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-04 16:26 PROBLEM: brcmfmac's DMI-based fw file names break built-in fw loader Victor Bravo
2019-05-04 19:11 ` Arend Van Spriel
2019-05-04 19:44 ` Victor Bravo
2019-05-05 8:20 ` Arend Van Spriel
2019-05-05 14:36 ` Victor Bravo
2019-05-05 14:48 ` [PATCH RFC] brcmfmac: sanitize DMI strings Victor Bravo
2019-05-05 14:52 ` Victor Bravo
2019-05-05 15:03 ` [PATCH RFC] brcmfmac: sanitize DMI strings v2 Victor Bravo
2019-05-06 8:13 ` Hans de Goede
2019-05-06 8:42 ` Kalle Valo
2019-05-06 9:14 ` Victor Bravo
2019-05-06 12:29 ` Kalle Valo [this message]
2019-05-06 14:06 ` Victor Bravo
2019-05-06 9:06 ` Victor Bravo
2019-05-06 9:33 ` Hans de Goede
2019-05-06 10:20 ` Victor Bravo
2019-05-06 10:34 ` Hans de Goede
2019-05-06 12:26 ` Kalle Valo
2019-05-06 15:24 ` Victor Bravo
2019-05-06 16:05 ` Hans de Goede
2019-05-06 19:30 ` Arend Van Spriel
2019-05-07 15:38 ` Hans de Goede
2019-05-13 9:21 ` Arend Van Spriel
2019-05-06 8:44 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878svjvk9q.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=1905@spmblk.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211-dev-list@cypress.com \
--cc=chi-hsien.lin@cypress.com \
--cc=davem@davemloft.net \
--cc=franky.lin@broadcom.com \
--cc=hante.meuleman@broadcom.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=wright.feng@cypress.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).