summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-10-09 05:10:49 +0200
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-10-09 05:10:49 +0200
commitd28eded6b9a40e603087e3abffcd6a12c60713a5 (patch)
treea36b487ec355b1c1383bd0c06b3a042032c3c7e2
parent[automerger skipped] Merge "Merge Android 12" am: 436a520a57 -s ours am: 60c3c08aa4 -s ours am: aaccc6518d -s ours am: 3ba15f2799 -s ours am: 4f8d5e5a4d -s ours (diff)
parentDo not write past end of inotify event structure. (diff)
downloadandroid_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar.gz
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar.bz2
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar.lz
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar.xz
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.tar.zst
android_bootable_recovery-d28eded6b9a40e603087e3abffcd6a12c60713a5.zip
-rw-r--r--minui/events.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/minui/events.cpp b/minui/events.cpp
index 87f811225..863ac7474 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -29,7 +29,9 @@
#include <functional>
#include <memory>
+#include <string>
+#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include "minui/minui.h"
@@ -118,12 +120,12 @@ static int inotify_cb(int fd, __unused uint32_t epevents) {
}
offset += sizeof(inotify_event) + pevent->len;
- pevent->name[pevent->len] = '\0';
- if (strncmp(pevent->name, "event", 5)) {
+ std::string event_name(pevent->name, pevent->len);
+ if (!android::base::StartsWith(event_name, "event")) {
continue;
}
- android::base::unique_fd dfd(openat(dirfd(dir.get()), pevent->name, O_RDONLY));
+ android::base::unique_fd dfd(openat(dirfd(dir.get()), event_name.c_str(), O_RDONLY));
if (dfd == -1) {
break;
}