Unsafe Temperature Parsing for NVMe #8

Open
opened 2026-02-02 14:45:58 -05:00 by jared · 0 comments
Owner

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))

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))
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/hwmonDaemon#8