Re: [PATCH v4] platform/x86: thinkpad_acpi: sysfs interface to auxmac

From: Ilpo Järvinen
Date: Mon Sep 25 2023 - 08:19:06 EST


On Fri, 22 Sep 2023, Fernando Eckhardt Valle (FIPT) wrote:

> Thanks for the feedback again!
>
> > Okay, I wasn't expecting this change as this relies on the nul termination
> > by strscpy() since the original buffer does not have one but the #
> > character there. But I guess it isn't harmful either.
> Yes, precisely because strscpy() put the 'nul terminator' I thought it
> would be ok. In the tests I did, everything always worked fine too.

It was a bit unorthodox way to take advantage of the way strscpy() works
but like I said, doesn't look harmful.

> > AUXMAC_START is an offset ??? It should be AUXMAC_LEN.
>
> I thought that since the string 'disabled' has length 8, then I would
> use AUXMAC_START which is defined as 9 , because that way strscpy would
> copy the 8 characters of 'disabled' + the nul terminator. Wouldn't that
> be correct? Or would it be better to use AUXMAC_LEN which is defined to
> 12?

strscpy() is takes the size of the destination:

* @size: Size of destination buffer

...so please use AUXMAC_LEN.

In anycase, "disabled" as the source is itself nul-terminated so strscpy()
won't copy beyond its length.


--
i.