Skip to content

better handling of gigantic config files

Jeff King git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6remote: drop auto-strlen behavior of make_branch() and make_rewrite()remote.c+12 -231 reply
2/6parse_config_key(): return subsection len as size_tarchive-tar.c builtin/help.c builtin/reflog.c +9 more+16 -150 replies
3/6config: drop useless length variable in write_pair()config.c+1 -31 reply
4/6git_config_parse_key(): return baselen as size_tconfig.c config.h+11 -80 replies
5/6config: use size_t to store parsed variable baselenconfig.c+1 -10 replies
6/6config: reject parsing of files over INT_MAXconfig.c+15 -04 replies

Reviews trailers per patch

None of the 6 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchTaylor Blau
SeriesR-b
1/6
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/6] better handling of gigantic config files

The fact that parse_config_key() requires its callers to use an "int" for a string length has bugged me for a while, and it re-bugged me when looking at it today. So I finally decided to do something about it, which led to an odyssey of other small fixes and cleanups.

In particular, I was curious what kinds of bad behavior you could provoke by having a key name larger than 2GB (especially because we use the same parser for .gitmodules files, which might not be trusted). It turns out: basically none, because the config parser chokes immediately dues to its own int/size_t confusion.

After patch 5, the config system _can_ actually handle stupidly-sized config keys, but in the end I decided to explicitly disallow them. There's downstream code that would be impossible to fix, and nobody actually cares about this case working anyway. See patch 6 for more discussion. I do still think the other patches are worth having as a cleanup; the more code that is safe from unexpected integer truncation the better.

[1/6]: remote: drop auto-strlen behavior of make_branch() and make_rewrite() [2/6]: parse_config_key(): return subsection len as size_t [3/6]: config: drop useless length variable in write_pair() [4/6]: git_config_parse_key(): return baselen as size_t
[5/6]: config: use size_t to store parsed variable baselen [6/6]: config: reject parsing of files over INT_MAX

 archive-tar.c      |  4 ++--
 builtin/help.c     |  2 +-
 builtin/reflog.c   |  2 +-
 config.c           | 42 +++++++++++++++++++++++++++++-------------
 config.h           |  4 ++--
 convert.c          |  2 +-
 fsck.c             |  2 +-
 ll-merge.c         |  2 +-
 promisor-remote.c  |  2 +-
 remote.c           | 37 +++++++++++++------------------------
 submodule-config.c |  3 ++-
 userdiff.c         |  4 ++--
 12 files changed, 56 insertions(+), 50 deletions(-)

-Peff