diff options
author | Steven Moreland <smoreland@google.com> | 2020-05-28 00:29:08 +0000 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2020-05-28 20:45:55 +0000 |
commit | 4048e49956a2dfd49af3adf0f78881bf15f3550f (patch) | |
tree | 6c8a3f0e21f3937801a0b369e1311fbc1ee277a1 /libutils/String16.cpp | |
parent | e62a9d7669ac85844d4424474f5c88c096f7160b (diff) |
String16::remove - avoid overflow
Bug: 156999009
Test: libutils_test (cases added)
Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
Merged-In: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
(cherry picked from commit f251c1c581f2d1b9940e60e756315c5e15443990)
(cherry picked from commit 9a9c8910e9296c9dc8d79c37f589895f5a2a836c)
Diffstat (limited to 'libutils/String16.cpp')
-rw-r--r-- | libutils/String16.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libutils/String16.cpp b/libutils/String16.cpp index e8f1c5184..7055fc6c3 100644 --- a/libutils/String16.cpp +++ b/libutils/String16.cpp @@ -402,7 +402,7 @@ status_t String16::remove(size_t len, size_t begin) mString = getEmptyString(); return NO_ERROR; } - if ((begin+len) > N) len = N-begin; + if (len > N || len > N - begin) len = N - begin; if (begin == 0 && len == N) { return NO_ERROR; } |