← Back to team overview

curtin-dev team mailing list archive

[Merge] ~sbykov/curtin:LP1895021 into curtin:master

 

Sergey Bykov has proposed merging ~sbykov/curtin:LP1895021 into curtin:master.

Commit message:
udevadm_info should use maxsplit=1 instead of maxsplit=2

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)

LP: #189502

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1895021 in curtin: "udevadm_info incorrectly splits string"
  https://bugs.launchpad.net/curtin/+bug/1895021

For more details, see:
https://code.launchpad.net/~sbykov/curtin/+git/curtin/+merge/390527
-- 
Your team curtin developers is requested to review the proposed merge of ~sbykov/curtin:LP1895021 into curtin:master.
diff --git a/curtin/udev.py b/curtin/udev.py
index f83f216..2b7a46e 100644
--- a/curtin/udev.py
+++ b/curtin/udev.py
@@ -90,9 +90,9 @@ def udevadm_info(path=None):
     for line in output.splitlines():
         if not line:
             continue
-        # maxsplit=2 gives us key and remaininng part of line is value
+        # maxsplit=1 gives us key and remaininng part of line is value
         # py2.7 on Trusty doesn't have keyword, pass as argument
-        key, value = line.split('=', 2)
+        key, value = line.split('=', 1)
         if not value:
             value = None
         if value:

Follow ups