Skip to content

Commit

Permalink
Make IGC reader more robust on nonsense input.
Browse files Browse the repository at this point in the history
  • Loading branch information
GPSBabelDeveloper committed Jun 30, 2017
1 parent ce052fe commit 24195b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions igc.cc
Expand Up @@ -170,7 +170,7 @@ static void igc_task_rec(const char* rec)
// First task record identifies the task to follow
if (id == state) {
task_desc[0] = '\0';
if (sscanf(rec, "C%2u%2u%2u%2u%2u%2u%6[0-9]%4c%2u%[^\r]\r\n",
if (sscanf(rec, "C%2u%2u%2u%2u%2u%2u%6[0-9]%4c%2u%79[^\r]\r\n",
&tm.tm_mday, &tm.tm_mon, &tm.tm_year,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec,
flight_date, task_num, &num_tp, task_desc) < 9) {
Expand All @@ -187,15 +187,14 @@ static void igc_task_rec(const char* rec)
// Create a route to store the task data in.
rte_head = route_head_alloc();
rte_head->rte_name = task_num;
sprintf(tmp_str, DATEMAGIC "%s: %s", flight_date, task_desc);
rte_head->rte_desc = tmp_str;
rte_head->rte_desc = QStringLiteral(DATEMAGIC) + flight_date + QStringLiteral(": ") + task_desc;
route_add_head(rte_head);
state++;
return;
}
// Get the waypoint
tmp_str[0] = '\0';
if (sscanf(rec, "C%2u%2u%3u%1[NS]%3u%2u%3u%1[WE]%[^\r]\r\n",
if (sscanf(rec, "C%2u%2u%3u%1[NS]%3u%2u%3u%1[WE]%79[^\r]\r\n",
&lat_deg, &lat_min, &lat_frac, lat_hemi,
&lon_deg, &lon_min, &lon_frac, lon_hemi, tmp_str) < 8) {
fatal(MYNAME ": task waypoint (C) record parse error\n%s", rec);
Expand Down

0 comments on commit 24195b5

Please sign in to comment.