From ad16eb112f4a9591acdf5f6f2981328613e6b626 Mon Sep 17 00:00:00 2001 From: "RELAUNCH DEPT." <215028820+ceodaradigu@users.noreply.github.com> Date: Thu, 3 Sep 2026 15:51:41 +0200 Subject: [PATCH] publickey: initialize the list terminator The allocation reserves `max_keys + 1` entries, while the initialization after growth currently covers only `max_keys - keys` entries. Include the additional reserved entry in that initialization so the list terminator is initialized at exact capacity boundaries. Follow-up to c2f1a3a21b4c922cbcf50bf7c009b740141a1e7a #2380 Ref: https://github.com/libssh2/libssh2/pull/2380#pullrequestreview-4746725158 Closes #2579 --- src/publickey.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/publickey.c b/src/publickey.c index d49ec48d38..36a60c141a 100644 --- a/src/publickey.c +++ b/src/publickey.c @@ -941,7 +941,8 @@ int libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey, goto err_exit; } list = newlist; - memset(&list[keys], 0, (max_keys - keys) * sizeof(list[keys])); + memset(&list[keys], 0, + (max_keys - keys + 1) * sizeof(list[keys])); } if(pkey->version == 1) { unsigned long comment_len;