fix: NMEA checksum validation and strtol error handling#53
Conversation
9cf9ab2 to
ab5f249
Compare
PR #53 Review: fix: NMEA checksum validation and strtol error handlingCI StatusGitHub Actions checks still IN PROGRESS (Build Firmware, Host Tests, CodeQL analyses). Cannot confirm CI passed yet. Code Review1. Docstring Behavior ChangeFile: * @return true if checksum valid, false if invalid or absent[BEST PRACTICE] [LOW]: The docstring now correctly documents that absent checksum returns 2.
|
| Category | Count | Severity |
|---|---|---|
| BUG | 0 | - |
| SECURITY | 0 | - |
| IMPROVEMENT | 1 | LOW |
| BEST PRACTICE | 3 | LOW |
CI not yet complete - Build Firmware and Host Tests still in progress. No blocking issues found. The fixes correctly address issues #39 and #40, and the GGA fix quality change is a good improvement.
|
All comments addressed:
Changes pushed to fix/nmea-checksum-strtol branch (commit d58283a). |
PR #53 Code ReviewCI Status
CI checks not yet complete - Build Firmware and Host Tests still running. Code Review of Changes1. Checksum Absent Behavior ChangeFile: if (!checksum_ptr) {
return false;
}[BEST PRACTICE] [LOW]: This is a breaking behavior change for callers. Previously 2. strtoul Error Handling - Good FixFile: char expected_str[3] = { checksum_ptr[1], checksum_ptr[2], '\0' };
char* endptr = NULL;
unsigned long expected = strtoul (expected_str, &endptr, 16);
if (endptr == expected_str || *endptr != '\0' || expected > 255) {
return false;
}
return calculated == (uint8_t)expected;[BEST PRACTICE] [LOW]: Excellent fix. Uses 3. GGA Fix Quality Range - Correct FixFile: data.has_fix = (field[0] >= '1' && field[0] <= '6');[BEST PRACTICE] [LOW]: Correct alignment with NMEA spec. Values 1-6 represent: 1=GPS fix, 2=DGPS, 3=PPS, 4=RTK, 5=Float RTK, 6=Estimated. Values 7, 8, 9 are undefined. Good fix. 4. Test Naming - Good UpdateFile: SECTION("Absent checksum fails") {[BEST PRACTICE] [LOW]: Clearer naming. "Absent" is more descriptive than "No checksum star". 5. Potential NULL Pointer Dereference - Pre-existingFile: inline bool
nmea_validate_checksum (const char* nmea, size_t len) {
const char* checksum_ptr = (const char*)memchr (nmea, '*', len);[SECURITY] [LOW]: No NULL check on Summary
CI not yet complete - no blocking issues found. The fixes correctly address issues #39 and #40. The strtoul error handling is particularly well-implemented with proper |


Summary
Fixes issues #39 and #40:
Issue #39 - NMEA checksum accepts missing checksum:
nmea_validate_checksum()to returnfalsewhen checksum is absentIssue #40 - strtol error handling broken:
endptrchecking to detect conversion failuresfalseif strtol fails to parse the checksum hex digitsAdditional fix:
Changes
firmware/main/nmea_parser.hpp:falsewhen*delimiter not found (line ~80)endptrchecking forstrtol(line ~94)Testing
Build passes for ESP32-S3 target.