Public bug reported:

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

** Affects: curtin
     Importance: Undecided
         Status: New

** Patch added: "0001-udevadm_info-incorrect-maxsplit-2-is-used.patch"
   
https://bugs.launchpad.net/bugs/1895021/+attachment/5409128/+files/0001-udevadm_info-incorrect-maxsplit-2-is-used.patch

-- 
You received this bug notification because you are a member of curtin
developers, which is subscribed to curtin.
https://bugs.launchpad.net/bugs/1895021

Title:
  udevadm_info incorrectly splits string

Status in curtin:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/curtin/+bug/1895021/+subscriptions

-- 
Mailing list: https://launchpad.net/~curtin-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~curtin-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to