git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] fsck: split ".gitmodules too large" error from parse failure

From
Jeff King <peff@peff.net>
Date
Jul 13, 2018, 19:39 UTC
Message-ID
<20180713193952.GA12162@sigill.intra.peff.net>
In-Reply-To
<20180713193759.GB10354@sigill.intra.peff.net>

Since ed8b10f631 (fsck: check .gitmodules content, 2018-05-02), we'll report a gitmodulesParse error for two conditions:

  - a .gitmodules entry is not syntactically valid
  - a .gitmodules entry is larger than core.bigFileThreshold

with the intent that we can detect malicious files and protect downstream clients. E.g., from the issue in 0383bbb901 (submodule-config: verify submodule names as paths, 2018-04-30).

But these conditions are actually quite different with respect to that bug:

 - a syntactically invalid file cannot trigger the problem,
   as the victim would barf before hitting the problematic
   code
 - a too-big .gitmodules _can_ trigger the problem. Even
   though it is obviously silly to have a 500MB .gitmodules
   file, the submodule code will happily parse it if you
   have enough memory.

So it may be reasonable to configure their severity separately. Let's add a new class for the "too large" case to allow that.

Signed-off-by: Jeff King <peff@peff.net>
---
 fsck.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fsck.c b/fsck.c
index 87b0e228bd..4129935d86 100644
--- a/fsck.c
+++ b/fsck.c
@@ -63,6 +63,7 @@ static struct oidset gitmodules_done = OIDSET_INIT;
 	FUNC(GITMODULES_MISSING, ERROR) \
 	FUNC(GITMODULES_BLOB, ERROR) \
 	FUNC(GITMODULES_PARSE, ERROR) \
+	FUNC(GITMODULES_LARGE, ERROR) \
 	FUNC(GITMODULES_NAME, ERROR) \
 	FUNC(GITMODULES_SYMLINK, ERROR) \
 	/* warnings */ \
@@ -1005,7 +1006,7 @@ static int fsck_blob(struct blob *blob, const char *buf,
 		 * that an error.
 		 */
 		return report(options, &blob->object,
-			      FSCK_MSG_GITMODULES_PARSE,
+			      FSCK_MSG_GITMODULES_LARGE,
 			      ".gitmodules too large to parse");
 	}
 
-- 
2.18.0.433.gb9621797ee
Previous: Jeff KingNext: Jeff King
Message 26 of 31 in “fsck: check skiplist for object in fsck_blob()”
  1. fsck: check skiplist for object in fsck_blob()Ramsay Jones, Jun 27, 2018
  2. Jeff KingJun 28, 2018
  3. Junio C HamanoJun 28, 2018
  4. Jeff KingJun 28, 2018
  5. Ramsay JonesJun 28, 2018
  6. Junio C HamanoJun 28, 2018
  7. Jeff KingJun 28, 2018
  8. Ramsay JonesJun 28, 2018
  9. Jeff KingJun 28, 2018
  10. 1/4 config: turn die_on_error into caller-facing enumJeff King, Jun 28, 2018
  11. 2/4 config: add CONFIG_ERROR_SILENT handlerJeff King, Jun 28, 2018
  12. 3/4 config: add options parameter to git_config_from_memJeff King, Jun 28, 2018
  13. 4/4 fsck: silence stderr when parsing .gitmodulesJeff King, Jun 28, 2018
  14. Jeff KingJun 28, 2018
  15. Ramsay JonesJun 29, 2018
  16. Ramsay JonesJun 29, 2018
  17. Jeff KingJul 3, 2018
  18. Ramsay JonesJul 4, 2018
  19. Jeff KingJul 7, 2018
  20. Ramsay JonesJul 11, 2018
  21. Ramsay JonesJul 13, 2018
  22. Jeff KingJul 13, 2018
  23. Jeff KingJul 13, 2018
  24. Ramsay JonesJul 13, 2018
  25. Jeff KingJul 13, 2018
  26. 1/2 fsck: split ".gitmodules too large" error from parse failureJeff King, Jul 13, 2018
  27. 2/2 fsck: downgrade gitmodulesParse default to "info"Jeff King, Jul 13, 2018
  28. Stefan BellerJul 13, 2018
  29. Junio C HamanoJul 16, 2018
  30. Jeff KingJul 16, 2018
  31. Junio C HamanoJul 16, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.