Skip to content

Commit

Permalink
Check for supported chars in name
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenc committed Aug 30, 2016
1 parent 44c4dfc commit 62a1e77
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gp102-poi.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ static void parse_coords(const char *arg, double *lat, double *lon)
}
}

static const char *supported = "0123456789-.:/_";

static int check_name(const char *name)
{
while (*name) {
if (!index(supported, *name))
return 1;
name++;
}
return 0;
}

static int write_poi(const char *name, const char *arg)
{
struct poi_data data = {
Expand All @@ -208,6 +220,10 @@ static int write_poi(const char *name, const char *arg)
};
double lat, lon;

if (check_name(name)) {
fprintf(stderr, "Error: unsupported char in name. Supported chars are: %s\n", supported);
return 1;
}
parse_coords(arg, &lat, &lon);

memset(&data.unused, 0xff, sizeof(data.unused));
Expand Down

0 comments on commit 62a1e77

Please sign in to comment.