diff options
author | Tianjie Xu <xunchang@google.com> | 2016-08-31 18:06:33 -0700 |
---|---|---|
committer | Tianjie Xu <xunchang@google.com> | 2016-08-31 19:11:41 -0700 |
commit | 71e182bc3879a53f04a50de9d25c333163cb7c76 (patch) | |
tree | 4f116fad73bb81476238deb9a70313f54cd68246 /applypatch/applypatch.cpp | |
parent | 818394869d36b9db1bf4984585a062d4bb91310f (diff) |
Check an edge case when read(2) returns 0
We might end up in an infinite loop if read(2) reached EOF unexpectedly.
The problematic code in uncrypt mentioned in the bug has been fixed
by switching to libbase ReadFully(). So I grepped through the recovery
code and fixed some other occurences of the issue.
Bug: 31073201
Change-Id: Ib867029158ba23363b8f85d61c25058a635c5a6b
Diffstat (limited to 'applypatch/applypatch.cpp')
-rw-r--r-- | applypatch/applypatch.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 02a3c6e4..e52ef99d 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -336,6 +336,9 @@ int WriteToPartition(const unsigned char* data, size_t len, const char* target) printf("verify read error %s at %zu: %s\n", partition, p, strerror(errno)); return -1; + } else if (read_count == 0) { + printf("verify read reached unexpected EOF, %s at %zu\n", partition, p); + return -1; } if (static_cast<size_t>(read_count) < to_read) { printf("short verify read %s at %zu: %zd %zu %s\n", |