1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

Make sure we pass right parameters to buffer_pack

Fixes: #299

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Norbert Pocs <norbertpocs0@gmail.com>
This commit is contained in:
Jakub Jelen
2025-04-14 22:17:02 +02:00
parent b14018ecab
commit d00f7b1bf9
5 changed files with 32 additions and 20 deletions

View File

@@ -1622,7 +1622,8 @@ static int channel_write_common(ssh_channel channel,
rc = ssh_buffer_pack(session->out_buffer,
"dP",
effectivelen,
(size_t)effectivelen, data);
(size_t)effectivelen,
data);
if (rc != SSH_OK) {
ssh_set_error_oom(session);
goto error;
@@ -1998,7 +1999,8 @@ int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *terminal
0, /* pix */
0, /* pix */
(uint32_t)modes_len,
modes_len, modes);
(size_t)modes_len,
modes);
if (rc != SSH_OK) {
ssh_set_error_oom(session);

View File

@@ -1077,7 +1077,7 @@ int ssh_send_kex(ssh_session session)
rc = ssh_buffer_pack(session->out_buffer,
"bP",
SSH2_MSG_KEXINIT,
16,
(size_t)16,
kex->cookie); /* cookie */
if (rc != SSH_OK)
goto error;
@@ -1409,10 +1409,10 @@ int ssh_make_sessionid(ssh_session session)
rc = ssh_buffer_pack(buf,
"dPdPS",
ssh_buffer_get_len(client_hash),
ssh_buffer_get_len(client_hash),
(size_t)ssh_buffer_get_len(client_hash),
ssh_buffer_get(client_hash),
ssh_buffer_get_len(server_hash),
ssh_buffer_get_len(server_hash),
(size_t)ssh_buffer_get_len(server_hash),
ssh_buffer_get(server_hash),
server_pubkey_blob);
SSH_STRING_FREE(server_pubkey_blob);
@@ -1514,9 +1514,11 @@ int ssh_make_sessionid(ssh_session session)
rc = ssh_buffer_pack(buf,
"dPdP",
CURVE25519_PUBKEY_SIZE,
(size_t)CURVE25519_PUBKEY_SIZE, session->next_crypto->curve25519_client_pubkey,
(size_t)CURVE25519_PUBKEY_SIZE,
session->next_crypto->curve25519_client_pubkey,
CURVE25519_PUBKEY_SIZE,
(size_t)CURVE25519_PUBKEY_SIZE, session->next_crypto->curve25519_server_pubkey);
(size_t)CURVE25519_PUBKEY_SIZE,
session->next_crypto->curve25519_server_pubkey);
if (rc != SSH_OK) {
ssh_set_error(session,

View File

@@ -786,7 +786,7 @@ static ssh_buffer ssh_msg_userauth_build_digest(ssh_session session,
rc = ssh_buffer_pack(buffer,
"dPbsssbsS",
crypto->session_id_len, /* session ID string */
(uint32_t)crypto->session_id_len, /* session ID string */
crypto->session_id_len,
crypto->session_id,
SSH2_MSG_USERAUTH_REQUEST, /* type */

View File

@@ -2638,10 +2638,14 @@ int ssh_pki_signature_verify(ssh_session session,
return SSH_ERROR;
}
rc = ssh_buffer_pack(sk_buffer, "PbdP",
SHA256_DIGEST_LEN, application_hash,
sig->sk_flags, sig->sk_counter,
SHA256_DIGEST_LEN, input_hash);
rc = ssh_buffer_pack(sk_buffer,
"PbdP",
(size_t)SHA256_DIGEST_LEN,
application_hash,
sig->sk_flags,
sig->sk_counter,
(size_t)SHA256_DIGEST_LEN,
input_hash);
if (rc != SSH_OK) {
SSH_BUFFER_FREE(sk_buffer);
explicit_bzero(input_hash, SHA256_DIGEST_LEN);
@@ -2735,7 +2739,8 @@ ssh_string ssh_pki_do_sign(ssh_session session,
rc = ssh_buffer_pack(sign_input,
"SP",
session_id,
ssh_buffer_get_len(sigbuf), ssh_buffer_get(sigbuf));
(size_t)ssh_buffer_get_len(sigbuf),
ssh_buffer_get(sigbuf));
if (rc != SSH_OK) {
goto end;
}

View File

@@ -552,7 +552,8 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
"ddPs",
rnd, /* checkint 1 & 2 */
rnd,
ssh_string_len(blob), ssh_string_data(blob),
ssh_string_len(blob),
ssh_string_data(blob),
"" /* comment */);
if (rc == SSH_ERROR){
goto error;
@@ -621,15 +622,17 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
rc = ssh_buffer_pack(buffer,
"PssSdSdP",
(size_t)strlen(OPENSSH_AUTH_MAGIC) + 1, OPENSSH_AUTH_MAGIC,
strlen(OPENSSH_AUTH_MAGIC) + 1,
OPENSSH_AUTH_MAGIC,
to_encrypt ? "aes128-cbc" : "none", /* ciphername */
to_encrypt ? "bcrypt" : "none", /* kdfname */
kdf_options, /* kdfoptions */
(uint32_t) 1, /* nkeys */
to_encrypt ? "bcrypt" : "none", /* kdfname */
kdf_options, /* kdfoptions */
(uint32_t)1, /* nkeys */
pubkey_s,
(uint32_t)ssh_buffer_get_len(privkey_buffer),
ssh_buffer_get_len(privkey_buffer),
/* rest of buffer is a string */
(size_t)ssh_buffer_get_len(privkey_buffer), ssh_buffer_get(privkey_buffer));
(size_t)ssh_buffer_get_len(privkey_buffer),
ssh_buffer_get(privkey_buffer));
if (rc != SSH_OK) {
goto error;
}