dpp, dpp-util: cast size_t for constant arguments to va_arg
James Prestwood
PATCH v2 1/1 dpp, dpp-util: cast size_t for constant arguments to va_arg
There were a few places in dpp/dpp-util which passed a single byte but was being read in with va_arg(va, size_t). On some architectures this was causing failures presumably from the compiler using an integer type smaller than size_t. As we do elsewhere, cast to size_t to force the compiler to pass a properly sized iteger to va_arg.
--- src/dpp-util.c | 6 ++++-- src/dpp.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
src/dpp-util.c +4 -2
@@ -571,7 +571,8 @@ bool dpp_derive_r_auth(const void *i_nonce, const void *r_nonce,* R-auth = H(I-nonce | R-nonce | PI.x | PR.x | [ BI.x | ] BR.x | 0) */ return dpp_hash (type, r_auth,6 , i_nonce, nonce_len, r_nonce, nonce_len, - pix, keys_len, prx, keys_len, brx, keys_len, &zero,1 ); + pix, keys_len, prx, keys_len, brx, keys_len, + &zero, (size_t )1 ); } bool dpp_derive_i_auth(const void *r_nonce, const void *i_nonce,
@@ -596,7 +597,8 @@ bool dpp_derive_i_auth(const void *r_nonce, const void *i_nonce,* I-auth = H(R-nonce | I-nonce | PR.x | PI.x | BR.x | [ BI.x | ] 1) */ return dpp_hash (type, i_auth,6 , r_nonce, nonce_len, i_nonce, nonce_len, - prx, keys_len, pix, keys_len, brx, keys_len, &one,1 ); + prx, keys_len, pix, keys_len, brx, keys_len, + &one, (size_t )1 ); }/*
src/dpp.c +6 -4
@@ -511,7 +511,7 @@ static void send_config_result(struct dpp_sm *dpp, const uint8_t *to) ptr +=dpp_append_wrapped_data (hdr +26 ,6 , attrs,0 , ptr,sizeof (attrs), dpp->ke, dpp->key_len,2 , -DPP_ATTR_STATUS ,1 , &zero, +DPP_ATTR_STATUS , (size_t )1 , &zero,DPP_ATTR_ENROLLEE_NONCE , dpp->nonce_len, dpp->e_nonce); iov[1 ].iov_base = attrs;
@@ -1146,7 +1146,7 @@ static void send_authenticate_response(struct dpp_sm *dpp) ptr,sizeof (attrs), dpp->k2, dpp->key_len,4 ,DPP_ATTR_RESPONDER_NONCE , dpp->nonce_len, dpp->r_nonce,DPP_ATTR_INITIATOR_NONCE , dpp->nonce_len, dpp->i_nonce, -DPP_ATTR_RESPONDER_CAPABILITIES ,1 , &dpp->role, +DPP_ATTR_RESPONDER_CAPABILITIES , (size_t )1 , &dpp->role, DPP_ATTR_WRAPPED_DATA, wrapped2_len, wrapped2); iov[1 ].iov_base = attrs;
@@ -1313,7 +1313,8 @@ static void dpp_auth_request_failed(struct dpp_sm *dpp, ptr +=dpp_append_wrapped_data (hdr +26 ,6 , attrs, ptr - attrs, ptr,sizeof (attrs) - (ptr - attrs), k1, dpp->key_len,2 ,DPP_ATTR_INITIATOR_NONCE , dpp->nonce_len, dpp->i_nonce, -DPP_ATTR_RESPONDER_CAPABILITIES ,1 , &dpp->role); +DPP_ATTR_RESPONDER_CAPABILITIES , + (size_t )1 , &dpp->role); iov[1 ].iov_base = attrs; iov[1 ].iov_len = ptr - attrs;
@@ -1404,7 +1405,8 @@ static bool dpp_send_authenticate_request(struct dpp_sm *dpp) ptr +=dpp_append_wrapped_data (hdr +26 ,6 , attrs, ptr - attrs, ptr,sizeof (attrs), dpp->k1, dpp->key_len,2 ,DPP_ATTR_INITIATOR_NONCE , dpp->nonce_len, dpp->i_nonce, -DPP_ATTR_INITIATOR_CAPABILITIES ,1 , &dpp->role); +DPP_ATTR_INITIATOR_CAPABILITIES , + (size_t )1 , &dpp->role); iov[1 ].iov_base = attrs; iov[1 ].iov_len = ptr - attrs;
Signature · 1 line
2.34.1
Denis Kenzior
AppliedRe: [PATCH v2] dpp,dpp-util: cast size_t for constant arguments to va_arg
Hi James,
Quoted 10 lines · James Prestwood
There were a few places in dpp/dpp-util which passed a single byte but was being read in with
va_arg(va, size_t). On some architectures this was causing failures presumably from the compiler using an integer type smaller thansize_t. As we do elsewhere, cast tosize_tto force the compiler to pass a properly sized iteger tova_arg.--- src/dpp-util.c | 6 ++++-- src/dpp.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-)
Applied, thanks.
Regards,
-Denis