Unsafe Temperature Parsing for NVMe #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lines 1706-1713 have a dangerous assumption:
digits = ''.join(c for c in temp_str if c.isdigit())
if len(digits) >= 2:
temp_value = int(digits[:2]) # Takes first 2 digits - could be wrong!
If temperature is "123°C", this gives "12" instead of "123". Fix:
Extract the first complete number
temp_match = re.search(r'(\d+)', temp_str)
if temp_match:
temp_value = int(temp_match.group(1))