{"thread":{"id":"4070","subject":"[PATCH] Fix for config file section parsing.","startedAt":"2006-05-05T13:49:15Z","lastAt":"2006-05-05T13:49:15Z","messageCount":1,"participants":["sean"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"19557","messageId":"BAYC1-PASMTP0769AAD931EFA5390875EDAEB50@CEZ.ICE","threadId":"4070","inReplyTo":null,"subject":"[PATCH] Fix for config file section parsing.","fromName":"sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-05-05T13:49:15Z","receivedAt":"2006-05-05T13:49:15Z","isPatch":true,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"Currently, if the target key has a section that matches\nthe initial substring of another section we mistakenly\nbelieve we've found the correct section.  To avoid this\nproblem, ensure that the section lengths are identical\nbefore comparison.\n\nSigned-off-by: Sean Estabrooks <seanlkml@sympatico.ca>\n\n---\n\nHere's an example of the problem:\n\n$ git repo-config a.b.c d\n$ cat .git/config\n[a.b]\n        c = d\n$ git repo-config a.x y\n$ cat .git/config\n[a.b]\n        c = d\n        x = y\n\n\n config.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\nf956fd1a6b1d3c82d9bc735427b58ec41d9e5dd1\ndiff --git a/config.c b/config.c\nindex 4e1f0c2..a3e14d7 100644\n--- a/config.c\n+++ b/config.c\n@@ -335,8 +335,9 @@ static int store_aux(const char* key, co\n \t\t\tstore.offset[store.seen] = ftell(config_file);\n \t\t\tstore.state = KEY_SEEN;\n \t\t\tstore.seen++;\n-\t\t} else if(!strncmp(key, store.key, store.baselen))\n-\t\t\tstore.state = SECTION_SEEN;\n+\t\t} else if (strrchr(key, '.') - key == store.baselen &&\n+\t\t\t      !strncmp(key, store.key, store.baselen))\n+\t\t\t\t\tstore.state = SECTION_SEEN;\n \t}\n \treturn 0;\n }\n-- \n1.3.2.g2fb9\n"}]}