1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00

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 c2f1a3a21b #2380
Ref: https://github.com/libssh2/libssh2/pull/2380#pullrequestreview-4746725158

Closes #2579
This commit is contained in:
RELAUNCH DEPT.
2026-09-03 15:51:41 +02:00
committed by Viktor Szakats
parent dc656fd807
commit ad16eb112f

View File

@@ -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;