Code

Fix for config file section parsing.
authorsean <seanlkml@sympatico.ca>
Fri, 5 May 2006 13:49:15 +0000 (09:49 -0400)
committerJunio C Hamano <junkio@cox.net>
Fri, 5 May 2006 21:33:58 +0000 (14:33 -0700)
Currently, if the target key has a section that matches
the initial substring of another section we mistakenly
believe we've found the correct section.  To avoid this
problem, ensure that the section lengths are identical
before comparison.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
config.c

index 4e1f0c22862b8c8605dbbf3a83ec4e87d9059513..a3e14d76e54e05887545765dabda11b1bc2af748 100644 (file)
--- a/config.c
+++ b/config.c
@@ -335,8 +335,9 @@ static int store_aux(const char* key, const char* value)
                        store.offset[store.seen] = ftell(config_file);
                        store.state = KEY_SEEN;
                        store.seen++;
-               } else if(!strncmp(key, store.key, store.baselen))
-                       store.state = SECTION_SEEN;
+               } else if (strrchr(key, '.') - key == store.baselen &&
+                             !strncmp(key, store.key, store.baselen))
+                                       store.state = SECTION_SEEN;
        }
        return 0;
 }