From 5ffdc9c5a4036f18e77274464e0c8fc1dcdbd416 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 3 Jan 2024 16:05:15 -0800 Subject: [PATCH] Fix the version length field when saving We need to write the length of the aligned buffer, not the length of the version string. Discovered in https://github.com/icsharpcode/ILSpy/issues/3068 --- src/dnmd/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dnmd/entry.c b/src/dnmd/entry.c index 427660ca..c93d78cb 100644 --- a/src/dnmd/entry.c +++ b/src/dnmd/entry.c @@ -830,7 +830,7 @@ bool md_write_to_buffer(mdhandle_t handle, uint8_t* buffer, size_t* len) size_t version_str_len = strlen(cxt->version); uint32_t version_buf_len = align_to((uint32_t)version_str_len + 1, 4); - if (!write_u32(&buffer, &remaining_buffer_len, (uint32_t)version_str_len + 1)) + if (!write_u32(&buffer, &remaining_buffer_len, (uint32_t)version_buf_len)) return false; if (remaining_buffer_len < version_buf_len)