More big-endian patches for the PS DB.
-Wyllys Ingersoll
--- src/tcs/ps/tcsps.c.old Wed Aug 5 11:59:24 2009
+++ src/tcs/ps/tcsps.c Wed Aug 5 12:03:55 2009
@@ -17,6 +17,9 @@
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
+#if defined (SOLARIS)
+#include <sys/byteorder.h>
+#endif
#include <assert.h>
#include <fcntl.h>
#include <limits.h>
@@ -603,28 +606,56 @@
}
/* [UINT16 pub_data_size0 ] yes */
+#ifdef _BIG_ENDIAN
+ pub_key_size = BSWAP_16(pub_key_size);
+#endif
if ((rc = write_data(fd, &pub_key_size, sizeof(UINT16)))) {
LogError("%s", __FUNCTION__);
goto done;
}
+#ifdef _BIG_ENDIAN
+ /* Swap it back for later */
+ pub_key_size = BSWAP_16(pub_key_size);
+#endif
/* [UINT16 blob_size0 ] yes */
+#ifdef _BIG_ENDIAN
+ key_blob_size = BSWAP_16(key_blob_size);
+#endif
if ((rc = write_data(fd, &key_blob_size, sizeof(UINT16)))) {
LogError("%s", __FUNCTION__);
goto done;
}
+#ifdef _BIG_ENDIAN
+ /* Swap it back for later */
+ key_blob_size = BSWAP_16(key_blob_size);
+#endif
/* [UINT32 vendor_data_size0 ] yes */
+#ifdef _BIG_ENDIAN
+ vendor_size = BSWAP_32(vendor_size);
+#endif
if ((rc = write_data(fd, &vendor_size, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
goto done;
}
+#ifdef _BIG_ENDIAN
+ /* Swap it back for later */
+ vendor_size = BSWAP_32(vendor_size);
+#endif
/* [UINT16 cache_flags0 ] yes */
+#ifdef _BIG_ENDIAN
+ cache_flags = BSWAP_16(cache_flags);
+#endif
if ((rc = write_data(fd, &cache_flags, sizeof(UINT16)))) {
LogError("%s", __FUNCTION__);
goto done;
}
+#ifdef _BIG_ENDIAN
+ /* Swap it back for later */
+ cache_flags = BSWAP_16(cache_flags);
+#endif
/* [BYTE[] pub_data0 ] no */
if ((rc = write_data(fd, (void *)key.pubKey.key, pub_key_size))) {
@@ -750,6 +781,9 @@
LogError("read of %zd bytes: %s", sizeof(UINT32),
strerror(errno));
return TCSERR(TSS_E_INTERNAL_ERROR);
}
+#ifdef _BIG_ENDIAN
+ num_keys = BSWAP_32(num_keys);
+#endif
rc = lseek(fd, TSSPS_NUM_KEYS_OFFSET, SEEK_SET);
if (rc == ((off_t) - 1)) {
@@ -760,6 +794,9 @@
/* decrement, then write back out to disk */
num_keys--;
+#ifdef _BIG_ENDIAN
+ num_keys = BSWAP_32(num_keys);
+#endif
if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
return result;
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech