Fix for config file section parsing.
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>
sean committed
May 5, 2006 at 09:49 UTC
93ddef3e2dd5f7f3238fad9d52e974d03c7844f2
1 file changed
+3
-2
config.c
+3
-2
@@ -335,8 +335,9 @@ static int store_aux(const char* key, const char* value)
335
store.offset[store.seen] = ftell(config_file);
336
store.state = KEY_SEEN;
337
store.seen++;
338
- } else if(!strncmp(key, store.key, store.baselen))
339
- store.state = SECTION_SEEN;
338
+ } else if (strrchr(key, '.') - key == store.baselen &&
339
+ !strncmp(key, store.key, store.baselen))
340
+ store.state = SECTION_SEEN;
341
}
342
return 0;
343
}