Skip to content

Commit

Permalink
ls-files: use correct format string
Browse files Browse the repository at this point in the history
struct stat_data and struct cache_time both use unsigned ints for all
their members.  However the format string for 'git ls-files --debug'
currently uses %d for formatting these numbers.  This means that we
potentially print these values incorrectly if they are greater than
INT_MAX.

This has been the case since the --debug option was introduced in 'git
ls-files' in 8497421 ("ls-files: learn a debugging dump format",
2010-07-31).

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
tgummerer authored and gitster committed Apr 8, 2019
1 parent aeb582a commit 7cb7283
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions builtin/ls-files.c
Expand Up @@ -112,11 +112,11 @@ static void print_debug(const struct cache_entry *ce)
if (debug_mode) {
const struct stat_data *sd = &ce->ce_stat_data;

printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
printf(" ctime: %u:%u\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
printf(" mtime: %u:%u\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
printf(" dev: %u\tino: %u\n", sd->sd_dev, sd->sd_ino);
printf(" uid: %u\tgid: %u\n", sd->sd_uid, sd->sd_gid);
printf(" size: %u\tflags: %x\n", sd->sd_size, ce->ce_flags);
}
}

Expand Down

0 comments on commit 7cb7283

Please sign in to comment.