aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recovery/recovery_updater.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/recovery/recovery_updater.cpp b/recovery/recovery_updater.cpp
index fcf04d8..24ba9d8 100644
--- a/recovery/recovery_updater.cpp
+++ b/recovery/recovery_updater.cpp
@@ -32,7 +32,6 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define ALPHABET_LEN 256
-#define KB 1024
#ifdef USES_BOOTDEVICE_PATH
#define BASEBAND_PART_PATH "/dev/block/bootdevice/by-name/modem"
@@ -42,7 +41,6 @@
#define BASEBAND_VER_STR_START "QC_IMAGE_VERSION_STRING=MPSS.DPM."
#define BASEBAND_VER_STR_START_LEN 33
#define BASEBAND_VER_BUF_LEN 255
-#define BASEBAND_SZ 64000 * KB /* MMAP 64M of BASEBAND, BASEBAND partition is 64M */
#ifdef USES_BOOTDEVICE_PATH
#define TZ_PART_PATH "/dev/block/bootdevice/by-name/tz"
@@ -52,7 +50,6 @@
#define TZ_VER_STR "QC_IMAGE_VERSION_STRING="
#define TZ_VER_STR_LEN 24
#define TZ_VER_BUF_LEN 255
-#define TZ_SZ 500 * KB /* MMAP 500K of TZ, TZ partition is 500K */
/* Boyer-Moore string search implementation from Wikipedia */
@@ -135,6 +132,7 @@ static char * bm_search(const char *str, size_t str_len, const char *pat,
static int get_baseband_version(char *ver_str, size_t len) {
int ret = 0;
int fd;
+ int baseband_size;
char *baseband_data = NULL;
char *offset = NULL;
@@ -144,21 +142,27 @@ static int get_baseband_version(char *ver_str, size_t len) {
goto err_ret;
}
- baseband_data = (char *) mmap(NULL, BASEBAND_SZ, PROT_READ, MAP_PRIVATE, fd, 0);
+ baseband_size = lseek64(fd, 0, SEEK_END);
+ if (baseband_size == -1) {
+ ret = errno;
+ goto err_fd_close;
+ }
+
+ baseband_data = (char *) mmap(NULL, baseband_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (baseband_data == (char *)-1) {
ret = errno;
goto err_fd_close;
}
/* Do Boyer-Moore search across BASEBAND data */
- offset = bm_search(baseband_data, BASEBAND_SZ, BASEBAND_VER_STR_START, BASEBAND_VER_STR_START_LEN);
+ offset = bm_search(baseband_data, baseband_size, BASEBAND_VER_STR_START, BASEBAND_VER_STR_START_LEN);
if (offset != NULL) {
strncpy(ver_str, offset + BASEBAND_VER_STR_START_LEN, len);
} else {
ret = -ENOENT;
}
- munmap(baseband_data, BASEBAND_SZ);
+ munmap(baseband_data, baseband_size);
err_fd_close:
close(fd);
err_ret:
@@ -168,6 +172,7 @@ err_ret:
static int get_tz_version(char *ver_str, size_t len) {
int ret = 0;
int fd;
+ int tz_size;
char *tz_data = NULL;
char *offset = NULL;
@@ -177,21 +182,27 @@ static int get_tz_version(char *ver_str, size_t len) {
goto err_ret;
}
- tz_data = (char *) mmap(NULL, TZ_SZ, PROT_READ, MAP_PRIVATE, fd, 0);
+ tz_size = lseek64(fd, 0, SEEK_END);
+ if (tz_size == -1) {
+ ret = errno;
+ goto err_fd_close;
+ }
+
+ tz_data = (char *) mmap(NULL, tz_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (tz_data == (char *)-1) {
ret = errno;
goto err_fd_close;
}
/* Do Boyer-Moore search across TZ data */
- offset = bm_search(tz_data, TZ_SZ, TZ_VER_STR, TZ_VER_STR_LEN);
+ offset = bm_search(tz_data, tz_size, TZ_VER_STR, TZ_VER_STR_LEN);
if (offset != NULL) {
strncpy(ver_str, offset + TZ_VER_STR_LEN, len);
} else {
ret = -ENOENT;
}
- munmap(tz_data, TZ_SZ);
+ munmap(tz_data, tz_size);
err_fd_close:
close(fd);
err_ret: