Skip to content

Commit

Permalink
lib: Use the full string length in strncmp() calls (#1060)
Browse files Browse the repository at this point in the history
The counts were off by one. Checking all characters now.
  • Loading branch information
infrastation committed Nov 17, 2020
1 parent ff33a47 commit 8070c64
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/gis/open.c
Expand Up @@ -59,7 +59,7 @@ static int G__open(const char *element,

G__check_gisinit();

is_tmp = (element && strncmp(element, ".tmp", 3) == 0);
is_tmp = (element && strncmp(element, ".tmp", 4) == 0);

/* READ */
if (mode == 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/ascii.c
Expand Up @@ -275,7 +275,7 @@ int Vect_read_ascii_head(FILE *dascii, struct Map_info *Map)
while (*ptr == ' ')
ptr++;

if (strncmp(buff, "ORGANIZATION:", 12) == 0)
if (strncmp(buff, "ORGANIZATION:", 13) == 0)
Vect_set_organization(Map, ptr);
else if (strncmp(buff, "DIGIT DATE:", 11) == 0)
Vect_set_date(Map, ptr);
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/header.c
Expand Up @@ -142,7 +142,7 @@ int Vect__read_head(struct Map_info *Map)
while (*ptr == ' ')
ptr++;

if (strncmp(buff, "ORGANIZATION:", sizeof(char) * 12) == 0)
if (strncmp(buff, "ORGANIZATION:", sizeof(char) * 13) == 0)
Vect_set_organization(Map, ptr);
else if (strncmp(buff, "DIGIT DATE:", sizeof(char) * 11) == 0)
Vect_set_date(Map, ptr);
Expand Down

0 comments on commit 8070c64

Please sign in to comment.