Skip to content

Commit

Permalink
Fix for config file section parsing.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sean authored and Junio C Hamano committed May 5, 2006
1 parent 7abd711 commit 93ddef3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 93ddef3

Please sign in to comment.