summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaeho Jeong <daehojeong@google.com>2023-03-28 20:15:53 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-03-28 20:15:53 +0000
commit13a57d2a26df5cbadaabc85dbef5084cdfd1293f (patch)
tree86a845802caa7869f205822f2f167b7138e045b9
parentc1572fe8cff4fcb825724a2ebc264919163c9e5b (diff)
parentdd08c52eb83a522c43d2f9be1293aeec36871534 (diff)
downloadvold-13a57d2a26df5cbadaabc85dbef5084cdfd1293f.tar.gz
Merge "vold: fix write kbytes handling"
-rw-r--r--IdleMaint.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/IdleMaint.cpp b/IdleMaint.cpp
index 0c6b1156..fedfc3d2 100644
--- a/IdleMaint.cpp
+++ b/IdleMaint.cpp
@@ -630,7 +630,12 @@ static int32_t getLifeTimeWrite() {
return -1;
}
- long long writeBytes = std::stoll(writeKbytesStr);
+ unsigned long long writeBytes = std::strtoull(writeKbytesStr.c_str(), NULL, 0);
+ /* Careful: values > LLONG_MAX can appear in the file due to a kernel bug. */
+ if (writeBytes / KBYTES_IN_SEGMENT > INT32_MAX) {
+ LOG(WARNING) << "Bad lifetime_write_kbytes: " << writeKbytesStr;
+ return -1;
+ }
return writeBytes / KBYTES_IN_SEGMENT;
}