Skip to contentSkip to conversation

dpp,dpp-util: use 'ULL' for constant arguments to va_arg

PATCH Superseded James Prestwood 1 participant 1 message Jun 3, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/1 dpp,dpp-util: use 'ULL' 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, use 1ULL to force the compiler to pass a properly sized iteger to va_arg.

---
 src/dpp-util.c | 6 ++++--
 src/dpp.c      | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
src/dpp-util.c +4 -2
index 8e7631d0..8cb37340 100644
@@ -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, 1ULL);
 }
 
 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, 1ULL);
 }
 
 /*
src/dpp.c +4 -4
index b70b9871..d6b312d7 100644
@@ -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, 1ULL, &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, 1ULL, &dpp->role,
 			DPP_ATTR_WRAPPED_DATA, wrapped2_len, wrapped2);
 
 	iov[1].iov_base = attrs;
@@ -1313,7 +1313,7 @@ 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, 1ULL, &dpp->role);
 
 	iov[1].iov_base = attrs;
 	iov[1].iov_len = ptr - attrs;
@@ -1404,7 +1404,7 @@ 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, 1ULL, &dpp->role);
 
 	iov[1].iov_base = attrs;
 	iov[1].iov_len = ptr - attrs;
Signature · 1 line
2.34.1