FBE for Pixel 2
Includes various minor fixes for building in Android 8 trees with r23+ tag
Update FBE extended header in libtar to version 2 and include the entire
ext4_encryption_policy structure now after translating the policy.
See this post for more details:
https://plus.google.com/u/1/+DeesTroy/posts/i33ygUi7tiu
Change-Id: I2af981e51f459b17fcd895fb8c2d3f6c8200e24b
diff --git a/adbbu/libtwadbbu.cpp b/adbbu/libtwadbbu.cpp
index 0c7f355..64e688c 100644
--- a/adbbu/libtwadbbu.cpp
+++ b/adbbu/libtwadbbu.cpp
@@ -30,6 +30,7 @@
#include <vector>
#include <fstream>
#include <sstream>
+#include <assert.h>
#include "twadbstream.h"
#include "libtwadbbu.hpp"
@@ -50,8 +51,8 @@
bytes = read(fd, &buf, sizeof(buf));
close(fd);
- if (memcpy(&adbbuhdr, buf, sizeof(adbbuhdr)) < 0) {
- printf("Unable to memcpy: %s.\n", fname.c_str(), strerror(errno));
+ if (memcpy(&adbbuhdr, buf, sizeof(adbbuhdr)) == NULL) {
+ printf("Unable to memcpy: %s (%s).\n", fname.c_str(), strerror(errno));
return false;
}
adbbuhdrcrc = adbbuhdr.crc;
@@ -77,7 +78,7 @@
while (1) {
std::string cmdstr;
int readbytes;
- if (readbytes = read(fd, &buf, sizeof(buf)) > 0) {
+ if ((readbytes = read(fd, &buf, sizeof(buf))) > 0) {
memcpy(&structcmd, buf, sizeof(structcmd));
assert(structcmd.type == TWENDADB || structcmd.type == TWIMG || structcmd.type == TWFN);
cmdstr = structcmd.type;