Commit 96d1886824 for frr

commit 96d18868247b379360261e181cfee58243a844de
Author: Grigorii Solovev <gs1571@gmail.com>
Date:   Fri Oct 9 12:30:00 2026 +0300

    tests: check SRv6 decoder writes against supplied buffer size

    Reset the guarded buffer before each boundary probe and check every byte
    at and beyond the supplied capacity. Cover zero-sized buffers for both
    empty and nonempty names, and the one-byte empty-name buffer.

    Add successful decoding of MAIN with exactly five bytes, including its
    terminator, while checking that the remaining bytes are unchanged.

    Signed-off-by: Grigorii Solovev <gs1571@gmail.com>

diff --git a/tests/lib/test_srv6_sid_notify.c b/tests/lib/test_srv6_sid_notify.c
index 71a997561d..56b70fcc12 100644
--- a/tests/lib/test_srv6_sid_notify.c
+++ b/tests/lib/test_srv6_sid_notify.c
@@ -77,6 +77,12 @@ static void test_names(void)
 	printf("Caller buffers retain independent names.\n");
 }

+static void assert_untouched_tail(const char *name, size_t size)
+{
+	for (size_t i = size; i < SRV6_LOCNAME_SIZE; i++)
+		assert((unsigned char)name[i] == 0xa5);
+}
+
 static void test_boundaries(void)
 {
 	struct {
@@ -97,23 +103,39 @@ static void test_boundaries(void)
 	stream_free(s);

 	for (size_t len = SRV6_LOCNAME_SIZE; len <= sizeof(payload); len++) {
+		memset(&guarded, 0xa5, sizeof(guarded));
 		s = notification(payload, len);
 		assert(!decode(s, guarded.name, sizeof(guarded.name)));
 		assert(guarded.before == 0xa5 && guarded.after == 0xa5);
 		stream_free(s);
 	}
 	for (size_t size = 0; size <= 4; size += 4) {
+		memset(&guarded, 0xa5, sizeof(guarded));
 		s = notification("MAIN", 4);
 		assert(!decode(s, guarded.name, size));
+		assert_untouched_tail(guarded.name, size);
 		assert(guarded.before == 0xa5 && guarded.after == 0xa5);
 		stream_free(s);
 	}
+	memset(&guarded, 0xa5, sizeof(guarded));
+	s = notification("MAIN", 4);
+	assert(decode(s, guarded.name, 5));
+	assert(!memcmp(guarded.name, "MAIN", 5));
+	assert_untouched_tail(guarded.name, 5);
+	assert(guarded.before == 0xa5 && guarded.after == 0xa5);
+	stream_free(s);
+	memset(&guarded, 0xa5, sizeof(guarded));
 	s = notification("", 0);
 	assert(!decode(s, guarded.name, 0));
+	assert_untouched_tail(guarded.name, 0);
+	assert(guarded.before == 0xa5 && guarded.after == 0xa5);
 	stream_free(s);
+	memset(&guarded, 0xa5, sizeof(guarded));
 	s = notification("", 0);
 	assert(decode(s, guarded.name, 1));
 	assert(guarded.name[0] == '\0');
+	assert_untouched_tail(guarded.name, 1);
+	assert(guarded.before == 0xa5 && guarded.after == 0xa5);
 	stream_free(s);
 	printf("Buffer boundaries reserve space for the terminator.\n");
 }