Переглянути джерело

lib: Use the full string length in strncmp() calls (#1060)

The counts were off by one. Checking all characters now.
Denis Ovsienko 4 роки тому
батько
коміт
8070c64c3a
3 змінених файлів з 3 додано та 3 видалено
  1. 1 1
      lib/gis/open.c
  2. 1 1
      lib/vector/Vlib/ascii.c
  3. 1 1
      lib/vector/Vlib/header.c

+ 1 - 1
lib/gis/open.c

@@ -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) {

+ 1 - 1
lib/vector/Vlib/ascii.c

@@ -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);

+ 1 - 1
lib/vector/Vlib/header.c

@@ -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);