udevadm_info incorrectly splits string
Bug #1895021 reported by
Sergey Bykov
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
curtin |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
In udevadm_info the below code is called to split output lines:
key, value = line.split('=', 2)
It can lead to unhandled exception if there are more than one equal sign in the string as split will return array of three or more elements. The correct way to get only two elements is
to use maxsplit=1:
key, value = line.split('=', 1)
For example:
>>> line = "1='2=3'"
>>> line.split('=', 2)
['1', "'2", "3'"]
>>> key, value = line.split('=', 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
Related branches
~sbykov/curtin:LP1895021
Merged
into
curtin:master
- Server Team CI bot: Approve (continuous-integration)
- Paride Legovini: Approve
-
Diff: 36 lines (+14/-2)2 files modifiedcurtin/udev.py (+2/-2)
tests/unittests/test_udev.py (+12/-0)
Changed in curtin: | |
status: | New → Confirmed |
Changed in curtin: | |
status: | Fix Committed → Fix Released |
status: | Fix Released → Fix Committed |
To post a comment you must log in.
Hi Sergey,
Thanks for the bug and the fix!
Would you be interested in contributing the fix? If so:
https:/ /curtin. readthedocs. io/en/latest/ topics/ hacking. html
I'm also interested in if you have actual udevadm info output that includes multiple '=' in a line.
The fix is 100% correct, just wondering if you ran into a real device with that included.