From b255e21e4848e70c0c87d485ddbe46fca5b94f9b Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Thu, 9 Mar 2023 16:00:54 -0500 Subject: [PATCH] Handle endianness in x509_inet_pton_ipv6() Signed-off-by: Glenn Strauss --- library/x509_crt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/x509_crt.c b/library/x509_crt.c index 7def3e992..64016a552 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -2579,7 +2579,7 @@ static int x509_inet_pton_ipv6(const char *src, void *dst) ; } if (j != 0) { - addr[i++] = (x << 8) | (x >> 8); /* htons(x) */ + addr[i++] = MBEDTLS_IS_BIG_ENDIAN ? x : (x << 8) | (x >> 8); if (*v == '\0') { break; } else if (*v == '.' && (i != 0 || dc != -1) && (i < 7) &&