Commit ef02e1c3 for guacamole.apache.org

commit ef02e1c36a60a1a0f9d75afb644468dddd2428b7
Author: Sertonix <sertonix@posteo.net>
Date:   Mon Oct 13 00:43:49 2025 +0200

    GUACAMOLE-2153: Fix GUAC_*_UTF16 on big-endian machine

    Since UTF-16 works with 16-bit values it has a byte order and that byte
    order is not well defined. There is a convention to use U+FEFF as first
    character which allows determining the endianess but it's commonly not
    present and doesn't seem to fit into the current code. The most common
    thing is to assume little-endian which is what I did here and is already
    implied by the test suite. If supporting both big- and little-endian
    UTF-16 is wanted one could create _UTF16LE and _UTF16BE variations of
    the functions.

diff --git a/src/common/iconv.c b/src/common/iconv.c
index c7da7e8b..8ff772ae 100644
--- a/src/common/iconv.c
+++ b/src/common/iconv.c
@@ -22,6 +22,7 @@

 #include <guacamole/unicode.h>
 #include <stdint.h>
+#include <endian.h>

 /**
  * Lookup table for Unicode code points, indexed by CP-1252 codepoint.
@@ -109,7 +110,7 @@ int GUAC_READ_UTF16(const char** input, int remaining) {
         return 0;

     /* Read two bytes as integer */
-    value = *((uint16_t*) *input);
+    value = le16toh(*((uint16_t*) *input));
     *input += 2;

     return value;
@@ -213,7 +214,7 @@ void GUAC_WRITE_UTF16(char** output, int remaining, int value) {
         return;

     /* Write two bytes as integer */
-    *((uint16_t*) *output) = value;
+    *((uint16_t*) *output) = htole16(value);
     *output += 2;

 }