From ffb41ce95ce706055b5063fcd3b070ef7d472da592b6f41d462087064db1208b Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 11 Dec 2024 16:41:13 +0300 Subject: [PATCH] Consider possible tail existence --- cyac/cmd/print-items/print-items.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cyac/cmd/print-items/print-items.c b/cyac/cmd/print-items/print-items.c index c1cc0d1..72331ca 100644 --- a/cyac/cmd/print-items/print-items.c +++ b/cyac/cmd/print-items/print-items.c @@ -355,13 +355,19 @@ main(int argc, char **argv) items.len, items.len * (sizeof(struct YACItem) + (NoOffsets ? 0 : sizeof(size_t)))); } + if (off < len) { + char *hex = HexEnc(buf + off, len - off); + printf("tail: %s\n", hex); + free(hex); + } if (doEncode) { unsigned char *dst = malloc(len); assert(dst != NULL); + size_t lenExpected = off; off = 0; assert(YACItemsEncode(&items, 0, &off, dst, len)); - assert(off == len); - assert(memcmp(dst, buf, len) == 0); + assert(off == lenExpected); + assert(memcmp(dst, buf, lenExpected) == 0); } return EXIT_SUCCESS; } -- 2.50.0