Added tests over potential directory-id checksum issues

- Checksum collisions
- Collisions with root did
- Collisions needing wraparound
- Possible leb128 encoding issues

Sure enough the last one caught an off-by-one error in our calculation
of the leb128 encoded size. I sort of expected a bug there, since it's
rather nuanced math, so it's good to have test coverage now.
This commit is contained in:
Christopher Haster
2023-07-06 15:44:53 -05:00
parent 21f7fd1032
commit f472327f74
2 changed files with 225 additions and 7 deletions
+2 -2
View File
@@ -1024,14 +1024,14 @@ typedef union lfsr_data {
#define LFSR_DATA_DNAME(_did, _buffer, _size) \
((lfsr_data_t){.buf={ \
/* note this find the effective leb128 size */ \
.size=_size + (lfs_nlog2(lfs_max32(_did, 1))+7-1)/7, \
.size=_size + (lfs_nlog2((_did)+1)+7-1)/7, \
.buffer=(const void*)(_buffer), \
.did=_did}})
#define LFSR_DATA_LEB128(_did) \
((lfsr_data_t){.buf={ \
/* note this find the effective leb128 size */ \
.size=(lfs_nlog2(lfs_max32(_did, 1))+7-1)/7, \
.size=(lfs_nlog2((_did)+1)+7-1)/7, \
.buffer=NULL, \
.did=_did}})