Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1709 - mtd_get_mac_ascii fails if the env has shrunk #8497

Open
openwrt-bot opened this issue Jul 29, 2018 · 0 comments
Open

FS#1709 - mtd_get_mac_ascii fails if the env has shrunk #8497

openwrt-bot opened this issue Jul 29, 2018 · 0 comments
Labels

Comments

@openwrt-bot
Copy link

ali1234:

In /lib/functions/system.sh is the code:

mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')

$part is the mtd containing the uboot environment.

When uboot writes its env it only erases sectors it needs to. If you delete a lot of env variables, later sectors can still contain old data. strings will read from those sectors and sed will potentially see multiple copies of the ethaddr variable. It can then output multiple copies of the ethaddr, which causes macaddr_canonicalize to reject the input because it is longer than 17 characters

A simple fix would be to do something like:

mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p' | head -n 1)

There may be a better way with some sed magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant