From 7d232078f2027dcde33f5ce2c695a9c164bc9a55 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 26 Feb 2024 02:34:18 -0600 Subject: [PATCH] Limited did generation to 31-bits Otherwise this risks overflowing 31-bit leb128 limits elsewhere in the system. I think at some point I was considering allowing _some_ types to be full 32-bit leb128s, mainly lfs_block_t and lfs_did_t, but at this point it doesn't seem worth the tradeoffs (especially if you can jump to 64-bits/63-bits in the future). It also never worked to be clear. --- lfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index 9f5a7fbf..3707fca1 100644 --- a/lfs.c +++ b/lfs.c @@ -8681,7 +8681,7 @@ int lfsr_mkdir(lfs_t *lfs, const char *path) { lfsr_did_t dmask = (1 << lfs_min32( lfs_nlog2(lfsr_mtree_weight(&lfs->mtree)) + lfs_nlog2(lfs->cfg->block_size/32), - 32)) - 1; + 31)) - 1; lfsr_did_t did_ = lfs_crc32c(0, path, strlen(path)) & dmask; // Check if we have a collision. If we do, search for the next