Blob Blame History Raw
autofs-5.0.4 - srv lookup handle endianness

From: Ian Kent <raven@themaw.net>


---

 modules/dclist.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/modules/dclist.c b/modules/dclist.c
index 5b0e577..967581c 100644
--- a/modules/dclist.c
+++ b/modules/dclist.c
@@ -34,6 +34,7 @@
 #include <ldap.h>
 #include <sys/param.h>
 #include <errno.h>
+#include <endian.h>
 
 #include "automount.h"
 #include "dclist.h"
@@ -72,8 +73,13 @@
 #define SVAL(buf, pos) (*(const uint16_t *)((const char *)(buf) + (pos)))
 #define IVAL(buf, pos) (*(const uint32_t *)((const char *)(buf) + (pos)))
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
 #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
+#else
+#define SREV(x) (x)
+#define IREV(x) (x)
+#endif
 
 #define RSVAL(buf, pos) SREV(SVAL(buf, pos))
 #define RIVAL(buf, pos) IREV(IVAL(buf, pos))