Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Unified Diff: src/tcs/ps/ps_utils.c

Issue 3581012: Upgrade from trousers 0.3.3 to 0.3.6 and from testsuite 0.2 to 0.3. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/trousers.git
Patch Set: git cl push Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/tcs/log.c ('k') | src/tcs/ps/tcsps.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tcs/ps/ps_utils.c
diff --git a/src/tcs/ps/ps_utils.c b/src/tcs/ps/ps_utils.c
index dc19cf3754253e5a800f1ede617842537fa9696b..82838ab26cccc3f802097d27aa10db9e78e80f48 100644
--- a/src/tcs/ps/ps_utils.c
+++ b/src/tcs/ps/ps_utils.c
@@ -1,4 +1,3 @@
-
/*
* Licensed Materials - Property of IBM
*
@@ -14,6 +13,18 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#if defined(HAVE_BYTEORDER_H)
+#include <sys/byteorder.h>
+#elif defined(HTOLE_DEFINED)
+#include <endian.h>
+#define LE_16 htole16
+#define LE_32 htole32
+#define LE_64 htole64
+#else
+#define LE_16(x) (x)
+#define LE_32(x) (x)
+#define LE_64(x) (x)
+#endif
#include <fcntl.h>
#include <string.h>
#include <limits.h>
@@ -133,6 +144,7 @@ write_key_init(int fd, UINT32 pub_data_size, UINT32 blob_size, UINT32 vendor_dat
/* read the number of keys */
rc = read(fd, &num_keys, sizeof(UINT32));
+ num_keys = LE_32(num_keys);
if (rc == -1) {
LogError("read of %zd bytes: %s", sizeof(UINT32), strerror(errno));
return -1;
@@ -160,6 +172,7 @@ write_key_init(int fd, UINT32 pub_data_size, UINT32 blob_size, UINT32 vendor_dat
return -1;
}
+ num_keys = LE_32(num_keys);
if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
return rc;
@@ -187,7 +200,7 @@ write_key_init(int fd, UINT32 pub_data_size, UINT32 blob_size, UINT32 vendor_dat
LogError("lseek: %s", strerror(errno));
return -1;
}
-
+ num_keys = LE_32(num_keys);
if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
return rc;
@@ -274,6 +287,7 @@ get_num_keys_in_file(int fd)
} else if ((unsigned)rc < sizeof(UINT32)) {
num_keys = 0;
}
+ num_keys = LE_32(num_keys);
return num_keys;
}
@@ -403,15 +417,16 @@ init_disk_cache(int fd)
LogError("%s", __FUNCTION__);
goto err_exit;
}
+ tmp->pub_data_size = LE_16(tmp->pub_data_size);
- DBG_ASSERT(tmp->pub_data_size <= 2048 && tmp->pub_data_size > 0);
+ //DBG_ASSERT(tmp->pub_data_size <= 2048 && tmp->pub_data_size > 0);
/* blob size */
if ((rc = read_data(fd, &tmp->blob_size, sizeof(UINT16)))) {
LogError("%s", __FUNCTION__);
goto err_exit;
}
-
+ tmp->blob_size = LE_16(tmp->blob_size);
DBG_ASSERT(tmp->blob_size <= 4096 && tmp->blob_size > 0);
/* vendor data size */
@@ -419,12 +434,14 @@ init_disk_cache(int fd)
LogError("%s", __FUNCTION__);
goto err_exit;
}
+ tmp->vendor_data_size = LE_32(tmp->vendor_data_size);
/* cache flags */
if ((rc = read_data(fd, &tmp->flags, sizeof(UINT16)))) {
LogError("%s", __FUNCTION__);
goto err_exit;
}
+ tmp->flags = LE_16(tmp->flags);
#ifdef TSS_DEBUG
if (tmp->flags & CACHE_FLAG_VALID)
« no previous file with comments | « src/tcs/log.c ('k') | src/tcs/ps/tcsps.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698