arduino / arduino/ArduinoCore-avr

parseFloat of Class Stream long int overflow

Open
#468 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Stream::parseFloat method use `long value;` to store temporary value before completion. But when encountering stream of number more than 2^32, this variable will overflow, and generate wrong results. Expect result should be returning float number with less precision, with correct orders of magnitude.

To replicate this bug: call `Serial.parseFloat()` when there is a number of more than 9 digits (include fraction digits) on a Serial stream.

One easy solution I can think of, is make the temporary variable `float` type.

Our solution for now is to read the whole number into a buffer, and use other method to convert to float.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the implementation of Stream::parseFloat and reproduce the issue with Serial.parseFloat() on a number exceeding nine digits, including fraction digits. Verify that the result preserves the correct order of magnitude while allowing reduced precision, and check the behavior against the reported overflow case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.