[U-Boot] [PATCH] common: nvedit to protect additional ethernet addresses Part 1/1
Jerry Van Baren
gvb.uboot at gmail.com
Sun Dec 7 03:53:02 CET 2008
Wolfgang Denk wrote:
> Dear Stefan Althoefer,
>
> In message <ghc625$k37$1 at ger.gmane.org> you wrote:
>> This patches cmd_nvedit to reject changes for "ethaddr." in addition to "ethaddr"
>> and "serial#". This is intendend to protect changes to additional ethernet
>> addresses (e.g. "ethernet1").
>
> The patch is bogus, as additional ethernet addrssses are eth1addr,
> eth2addr, etc. and not ethaddr1, etc.
>
>
> Also, please don't remove perfectly god comments.
>
> NAK.
>
> Best regards,
>
> Wolfgang Denk
Arrgh, I was thinking I was so clever with strncmp() and it turns out I
was being clever based on a totally bogus assumption (wrong format).
:-( I *hate* it when that happens.
The following should work for eth[0-9]+addr (untested):
int ethnum;
:
:
/* "eth[0-9]+addr" is always protected */
if ((sscanf(name, "eth%daddr", ðnum) == 1) &&
(ethnum < MAX_ETH_ADDRS))
protected = 1;
Notes:
* The "ethaddr" case is handled prior to the above snippet of code.
* I took out the added check "if (strlen (name) == 8)", I'm not sure why
that was in there, it would limit us to 10 ethernets. If extra
validation is desired, ethnum could be checked to be less than
MAX_ETH_ADDRS. On reflection, it seems like a good idea so I added it
above.
* This is somewhat better than the strncmp() trick because the sscanf()
will only convert digits.
gvb
More information about the U-Boot
mailing list