am 4854e292: am ad509fd4: Merge "Fix potential crash"

* commit '4854e292e0cd0eb58bce4488dc849273904d9302':
  Fix potential crash
This commit is contained in:
Tao Bao
2015-08-11 16:23:58 +00:00
committed by Android Git Automerger
+4
View File
@@ -1036,12 +1036,16 @@ main(int argc, char **argv) {
if (strncmp(update_package, "CACHE:", 6) == 0) { if (strncmp(update_package, "CACHE:", 6) == 0) {
int len = strlen(update_package) + 10; int len = strlen(update_package) + 10;
char* modified_path = (char*)malloc(len); char* modified_path = (char*)malloc(len);
if (modified_path) {
strlcpy(modified_path, "/cache/", len); strlcpy(modified_path, "/cache/", len);
strlcat(modified_path, update_package+6, len); strlcat(modified_path, update_package+6, len);
printf("(replacing path \"%s\" with \"%s\")\n", printf("(replacing path \"%s\" with \"%s\")\n",
update_package, modified_path); update_package, modified_path);
update_package = modified_path; update_package = modified_path;
} }
else
printf("modified_path allocation failed\n");
}
} }
printf("\n"); printf("\n");