Changing the number of available temporary buffers for get_pathname() can help diagnose abuse of such buffers. If a bug goes away when PATHNAME_BUFFER_COUNT is increased, then it might be due to a buffer being used after it has been recycled. Similarly, if a bug appears when PATHNAME_BUFFER_COUNT is decreased, then there might be a latent problem that could emerge after unrelated code changes. Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> --- path.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git path.c path.c index 6f3f5d5..6c4714d 100644 --- path.c +++ path.c @@ -13,13 +13,16 @@ #include "cache.h" #include "strbuf.h" +/* This must be a power of 2: */ +#define PATHNAME_BUFFER_COUNT (1 << 2) + static char bad_path[] = "/bad-path/"; static char *get_pathname(void) { - static char pathname_array[4][PATH_MAX]; + static char pathname_array[PATHNAME_BUFFER_COUNT][PATH_MAX]; static int index; - return pathname_array[3 & ++index]; + return pathname_array[(PATHNAME_BUFFER_COUNT - 1) & ++index]; } static char *cleanup_path(char *path) -- 1.7.7.rc2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html