diff options
author | Jeremy Compostella <jeremy.compostella@intel.com> | 2015-07-29 17:17:03 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 19:21:20 -0800 |
commit | 76b04d4eee83b6f90fce4c2d0cebe191243494eb (patch) | |
tree | 9b65a593bc59d43b422833f25260e55f9670a0d5 /recovery.cpp | |
parent | a6ef5d0e71f81cc8697328e7f64f841943cba0dc (diff) | |
download | bootable_recovery-76b04d4eee83b6f90fce4c2d0cebe191243494eb.zip bootable_recovery-76b04d4eee83b6f90fce4c2d0cebe191243494eb.tar.gz bootable_recovery-76b04d4eee83b6f90fce4c2d0cebe191243494eb.tar.bz2 |
Fix potential crash
Malloc might fail when replacing package path. In this case, print a
clear error message in the logs and let the OTA fails.
Change-Id: I7209d95edc025e3ee1b4478f5e04f6e852d97205
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Gaelle Nassiet <gaellex.nassiet@intel.com>
Diffstat (limited to 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/recovery.cpp b/recovery.cpp index b7f1e4a..a43f321 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1036,11 +1036,15 @@ main(int argc, char **argv) { if (strncmp(update_package, "CACHE:", 6) == 0) { int len = strlen(update_package) + 10; char* modified_path = (char*)malloc(len); - strlcpy(modified_path, "/cache/", len); - strlcat(modified_path, update_package+6, len); - printf("(replacing path \"%s\" with \"%s\")\n", - update_package, modified_path); - update_package = modified_path; + if (modified_path) { + strlcpy(modified_path, "/cache/", len); + strlcat(modified_path, update_package+6, len); + printf("(replacing path \"%s\" with \"%s\")\n", + update_package, modified_path); + update_package = modified_path; + } + else + printf("modified_path allocation failed\n"); } } printf("\n"); |