From 1ce7a2a63db84527e6195a6b123b1617f87c0f38 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 24 Jul 2015 15:29:12 -0700 Subject: [PATCH] applypatch: Fix the checking in WriteToPartition(). WriteToPartition() should consider a target name as valid if it contains multiple colons. But only the first two fields will be used. Bug: 22725128 Change-Id: Ie9404375e24045c115595eec6ce5b6423da8fc3e --- applypatch/applypatch.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 2446b2a6..751d3e39 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -312,13 +312,14 @@ int SaveFileContents(const char* filename, const FileContents* file) { } // Write a memory buffer to 'target' partition, a string of the form -// "MTD:[:...]" or "EMMC:". Return 0 on -// success. +// "MTD:[:...]" or "EMMC:[:...]". The target name +// might contain multiple colons, but WriteToPartition() only uses the first +// two and ignores the rest. Return 0 on success. int WriteToPartition(unsigned char* data, size_t len, const char* target) { std::string copy(target); std::vector pieces = android::base::Split(copy, ":"); - if (pieces.size() != 2) { + if (pieces.size() < 2) { printf("WriteToPartition called with bad target (%s)\n", target); return -1; }