[msitools] Replace le16toh with glib GUINT_FROM_LE



commit 9bbcc6da06ccf6144258c26ddcaab3262538d3ce
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Thu Jan 16 13:37:24 2020 +0400

    Replace le16toh with glib GUINT_FROM_LE
    
    This should fix:
    https://gitlab.gnome.org/GNOME/msitools/issues/15
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 libmsi/string.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/libmsi/string.c b/libmsi/string.c
index 2a696e3..988d6eb 100644
--- a/libmsi/string.c
+++ b/libmsi/string.c
@@ -22,11 +22,6 @@
 
 #include <stdarg.h>
 #include <assert.h>
-#ifdef __FreeBSD__
-#  include <sys/endian.h>
-#else
-#  include <endian.h>
-#endif
 #include <gsf/gsf-msole-utils.h>
 
 #include "debug.h"
@@ -500,14 +495,14 @@ string_table *msi_load_string_table( GsfInfile *stg, unsigned *bytes_per_strref
     if( r != LIBMSI_RESULT_SUCCESS)
         goto end;
 
-    if ( (poolsize > 4) && (le16toh(pool[1]) & 0x8000) )
+    if ( (poolsize > 4) && (GUINT_FROM_LE(pool[1]) & 0x8000) )
         *bytes_per_strref = LONG_STR_BYTES;
     else
         *bytes_per_strref = sizeof(uint16_t);
 
     count = poolsize/4;
     if( poolsize > 4 )
-        codepage = le16toh(pool[0]) | ( (le16toh(pool[1]) & ~0x8000) << 16 );
+        codepage = GUINT_FROM_LE(pool[0]) | ( (GUINT_FROM_LE(pool[1]) & ~0x8000) << 16 );
     else
         codepage = CP_ACP;
 
@@ -521,10 +516,10 @@ string_table *msi_load_string_table( GsfInfile *stg, unsigned *bytes_per_strref
     while ( i<count )
     {
         /* the string reference count is always the second word */
-        refs = le16toh(pool[i*2+1]);
+        refs = GUINT_FROM_LE(pool[i*2+1]);
 
         /* empty entries have two zeros, still have a string id */
-        if (le16toh(pool[i*2]) == 0 && refs == 0)
+        if (GUINT_FROM_LE(pool[i*2]) == 0 && refs == 0)
         {
             i++;
             n++;
@@ -536,14 +531,14 @@ string_table *msi_load_string_table( GsfInfile *stg, unsigned *bytes_per_strref
          * and the high word of the length is inserted in the null string's
          * reference count field.
          */
-        if (le16toh(pool[i*2]) == 0)
+        if (GUINT_FROM_LE(pool[i*2]) == 0)
         {
-            len = (le16toh(pool[i*2+3]) << 16) + le16toh(pool[i*2+2]);
+            len = (GUINT_FROM_LE(pool[i*2+3]) << 16) + GUINT_FROM_LE(pool[i*2+2]);
             i += 2;
         }
         else
         {
-            len = le16toh(pool[i*2]);
+            len = GUINT_FROM_LE(pool[i*2]);
             i += 1;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]