mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
pki_mbedcrypto: Use SSH_STRING_FREE()
Fixes T183 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -596,7 +596,7 @@ ssh_string make_ecpoint_string(const mbedtls_ecp_group *g, const
|
|||||||
rc = mbedtls_ecp_point_write_binary(g, p, MBEDTLS_ECP_PF_UNCOMPRESSED,
|
rc = mbedtls_ecp_point_write_binary(g, p, MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||||
&len, ssh_string_data(s), ssh_string_len(s));
|
&len, ssh_string_data(s), ssh_string_len(s));
|
||||||
if (rc == MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) {
|
if (rc == MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) {
|
||||||
ssh_string_free(s);
|
SSH_STRING_FREE(s);
|
||||||
|
|
||||||
s = ssh_string_new(len);
|
s = ssh_string_new(len);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
@@ -608,12 +608,12 @@ ssh_string make_ecpoint_string(const mbedtls_ecp_group *g, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
ssh_string_free(s);
|
SSH_STRING_FREE(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len != ssh_string_len(s)) {
|
if (len != ssh_string_len(s)) {
|
||||||
ssh_string_free(s);
|
SSH_STRING_FREE(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,7 +667,7 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, type_s);
|
rc = ssh_buffer_add_ssh_string(buffer, type_s);
|
||||||
ssh_string_free(type_s);
|
SSH_STRING_FREE(type_s);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_buffer_free(buffer);
|
ssh_buffer_free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -702,10 +702,10 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssh_string_burn(e);
|
ssh_string_burn(e);
|
||||||
ssh_string_free(e);
|
SSH_STRING_FREE(e);
|
||||||
e = NULL;
|
e = NULL;
|
||||||
ssh_string_burn(n);
|
ssh_string_burn(n);
|
||||||
ssh_string_free(n);
|
SSH_STRING_FREE(n);
|
||||||
n = NULL;
|
n = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -721,7 +721,7 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(buffer, type_s);
|
rc = ssh_buffer_add_ssh_string(buffer, type_s);
|
||||||
ssh_string_free(type_s);
|
SSH_STRING_FREE(type_s);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_buffer_free(buffer);
|
ssh_buffer_free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -740,7 +740,7 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssh_string_burn(e);
|
ssh_string_burn(e);
|
||||||
ssh_string_free(e);
|
SSH_STRING_FREE(e);
|
||||||
e = NULL;
|
e = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -770,11 +770,11 @@ makestring:
|
|||||||
fail:
|
fail:
|
||||||
ssh_buffer_free(buffer);
|
ssh_buffer_free(buffer);
|
||||||
ssh_string_burn(str);
|
ssh_string_burn(str);
|
||||||
ssh_string_free(str);
|
SSH_STRING_FREE(str);
|
||||||
ssh_string_burn(e);
|
ssh_string_burn(e);
|
||||||
ssh_string_free(e);
|
SSH_STRING_FREE(e);
|
||||||
ssh_string_burn(n);
|
ssh_string_burn(n);
|
||||||
ssh_string_free(n);
|
SSH_STRING_FREE(n);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -807,7 +807,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(b, r);
|
rc = ssh_buffer_add_ssh_string(b, r);
|
||||||
ssh_string_free(r);
|
SSH_STRING_FREE(r);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_buffer_free(b);
|
ssh_buffer_free(b);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -820,7 +820,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(b, s);
|
rc = ssh_buffer_add_ssh_string(b, s);
|
||||||
ssh_string_free(s);
|
SSH_STRING_FREE(s);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_buffer_free(b);
|
ssh_buffer_free(b);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -971,7 +971,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
#endif
|
#endif
|
||||||
sig->ecdsa_sig.r = ssh_make_string_bn(r);
|
sig->ecdsa_sig.r = ssh_make_string_bn(r);
|
||||||
ssh_string_burn(r);
|
ssh_string_burn(r);
|
||||||
ssh_string_free(r);
|
SSH_STRING_FREE(r);
|
||||||
if (sig->ecdsa_sig.r == NULL) {
|
if (sig->ecdsa_sig.r == NULL) {
|
||||||
ssh_buffer_free(b);
|
ssh_buffer_free(b);
|
||||||
ssh_signature_free(sig);
|
ssh_signature_free(sig);
|
||||||
@@ -991,7 +991,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
#endif
|
#endif
|
||||||
sig->ecdsa_sig.s = ssh_make_string_bn(s);
|
sig->ecdsa_sig.s = ssh_make_string_bn(s);
|
||||||
ssh_string_burn(s);
|
ssh_string_burn(s);
|
||||||
ssh_string_free(s);
|
SSH_STRING_FREE(s);
|
||||||
if (sig->ecdsa_sig.s == NULL) {
|
if (sig->ecdsa_sig.s == NULL) {
|
||||||
ssh_signature_free(sig);
|
ssh_signature_free(sig);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user