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: I9d0236eaf97df9db9704acf53690d0ef85188e45
(cherry picked from commit 1ce7a2a63d
)
This commit is contained in:
parent
f47259b184
commit
32ac97675b
1 changed files with 4 additions and 3 deletions
|
@ -312,13 +312,14 @@ int SaveFileContents(const char* filename, const FileContents* file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a memory buffer to 'target' partition, a string of the form
|
// Write a memory buffer to 'target' partition, a string of the form
|
||||||
// "MTD:<partition>[:...]" or "EMMC:<partition_device>". Return 0 on
|
// "MTD:<partition>[:...]" or "EMMC:<partition_device>[:...]". The target name
|
||||||
// success.
|
// 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) {
|
int WriteToPartition(unsigned char* data, size_t len, const char* target) {
|
||||||
std::string copy(target);
|
std::string copy(target);
|
||||||
std::vector<std::string> pieces = android::base::Split(copy, ":");
|
std::vector<std::string> pieces = android::base::Split(copy, ":");
|
||||||
|
|
||||||
if (pieces.size() != 2) {
|
if (pieces.size() < 2) {
|
||||||
printf("WriteToPartition called with bad target (%s)\n", target);
|
printf("WriteToPartition called with bad target (%s)\n", target);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue