Skip to content

bug: strtol error handling broken in NMEA parser #40

@gdellis

Description

@gdellis

Problem

In nmea_parser.hpp:95, strtol is used without checking errno or using the endptr parameter. When strtol fails to parse, it returns 0. When it successfully parses the string "0", it also returns 0. There's no way to distinguish between an error and a valid zero value.

Location

  • firmware/main/nmea_parser.hpp:95

Severity

HIGH - Invalid hex values silently treated as valid zeros

Suggested Fix

Use strtol with proper endptr checking:

char* endptr;
uint8_t expected = (uint8_t)strtol(expected_str, &endptr, 16);
if (endptr == expected_str || *endptr != '\0') return false;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions