[Bug 1761341] Re: lsb_release crashed with ValueError in <lambda>(): could not convert string to float: '6.06 LTS'
Ioanna Alifieraki
1761341 at bugs.launchpad.net
Mon Sep 19 11:33:47 UTC 2022
@mwhudson yes, I am working on the debdiffs and once ready I'll attach
them here.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to lsb in Ubuntu.
https://bugs.launchpad.net/bugs/1761341
Title:
lsb_release crashed with ValueError in <lambda>(): could not convert
string to float: '6.06 LTS'
Status in lsb package in Ubuntu:
Fix Released
Status in lsb source package in Bionic:
Confirmed
Status in lsb source package in Focal:
Confirmed
Status in lsb source package in Jammy:
Confirmed
Bug description:
[Description]
In some cases lsb_release script can crash with the following trace :
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 95, in <module>
main()
File "/usr/bin/lsb_release", line 59, in main
distinfo = lsb_release.get_distro_information()
File "/usr/lib/python3/dist-packages/lsb_release.py", line 356, in
get_distro_information
distinfo = guess_debian_release()
File "/usr/lib/python3/dist-packages/lsb_release.py", line 246, in
guess_debian_release
get_distro_info(distinfo['ID'])
File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in
get_distro_info
RELEASES_ORDER.sort(key=lambda n: float(n[0]))
File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in <lambda>
RELEASES_ORDER.sort(key=lambda n: float(n[0]))
ValueError: could not convert string to float: '6.06 LTS
The root cause of this is that function get_distro_info() while parsing
the '/usr/share/distro-info/ubuntu.csv' and expects to find a float at the
beginning of each line, instead it find a string ("6.06 LTS").
There is a fix for this bug upstream:
https://salsa.debian.org/debian/lsb/-/commit/4b36f9d31c00233ea20415542633729ab3799e61
and is already in kinetic.
[Test Case]
The easier way to reproduce this bug is to hack /usr/share/pyshared/lsb_release.py file
change the get_distro_info definition from
def get_distro_info(origin='Debian'):
to
def get_distro_info(origin='Ubuntu'):
and run
$ lsb_release
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 25, in <module>
import lsb_release
File "/usr/lib/python3/dist-packages/lsb_release.py", line 58, in <module>
get_distro_info()
File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in get_distro_info
RELEASES_ORDER.sort(key=lambda n: float(n[0]))
File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in <lambda>
RELEASES_ORDER.sort(key=lambda n: float(n[0]))
ValueError: could not convert string to float: '6.06 LTS'
A detailed analysis on how this bug can happen in a real life scenario
can be found in comment #3.
[Regression Potential]
The fix changes the way get_distro_info function parses the csv file and instead of expecting
a float at the beginning of the line, it now expects a string and isolates the numerical part.
The regression potential is small and would affect the behavior of
lsb_release executable.
[Other]
Debian bug : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980566
Fix : https://salsa.debian.org/debian/lsb/-/commit/4b36f9d31c00233ea20415542633729ab3799e61
Affected releases : Jammy, Focal, Bionic
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/1761341/+subscriptions
More information about the foundations-bugs
mailing list