adding some bounds checking in nmea parser (which sucks and should just go away anyway)

This commit is contained in:
dongie 2014-04-10 10:57:47 +09:00
parent fc1f5c9f1e
commit fafc59b3a5
2 changed files with 2715 additions and 2710 deletions

File diff suppressed because it is too large Load Diff

View File

@ -850,8 +850,10 @@ uint32_t GPS_coord_to_degrees(char* s)
int i;
// scan for decimal point or end of field
for (p = s; isdigit((unsigned char)*p); p++)
;
for (p = s; isdigit((unsigned char)*p); p++) {
if (p >= s + 15)
return 0; // stop potential fail
}
q = s;
// convert degrees
@ -896,6 +898,8 @@ static uint32_t grab_fields(char *src, uint8_t mult)
tmp *= 10;
if (src[i] >= '0' && src[i] <= '9')
tmp += src[i] - '0';
if (i >= 15)
return 0; // out of bounds
}
return tmp;
}