Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a84bd46 authored by Xin Long's avatar Xin Long Committed by David S. Miller
Browse files

sctp: translate network order to host order when users get a hmacid



Commit ed5a377d ("sctp: translate host order to network order when
setting a hmacid") corrected the hmacid byte-order when setting a hmacid.
but the same issue also exists on getting a hmacid.

We fix it by changing hmacids to host order when users get them with
getsockopt.

Fixes: Commit ed5a377d ("sctp: translate host order to network order when setting a hmacid")
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca7f41a4
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -5538,6 +5538,7 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
	struct sctp_hmac_algo_param *hmacs;
	struct sctp_hmac_algo_param *hmacs;
	__u16 data_len = 0;
	__u16 data_len = 0;
	u32 num_idents;
	u32 num_idents;
	int i;


	if (!ep->auth_enable)
	if (!ep->auth_enable)
		return -EACCES;
		return -EACCES;
@@ -5555,8 +5556,12 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
		return -EFAULT;
		return -EFAULT;
	if (put_user(num_idents, &p->shmac_num_idents))
	if (put_user(num_idents, &p->shmac_num_idents))
		return -EFAULT;
		return -EFAULT;
	if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len))
	for (i = 0; i < num_idents; i++) {
		__u16 hmacid = ntohs(hmacs->hmac_ids[i]);

		if (copy_to_user(&p->shmac_idents[i], &hmacid, sizeof(__u16)))
			return -EFAULT;
			return -EFAULT;
	}
	return 0;
	return 0;
}
}