Do not write past end of inotify event structure. am: 187a6ec548

Original change: https://googleplex-android-review.googlesource.com/c/platform/bootable/recovery/+/16033753

Change-Id: Iee43ca1dde2fbb897e228ee092100d7a739a1bb6
This commit is contained in:
Christopher Ferris 2021-10-12 14:23:35 +00:00 committed by Automerger Merge Worker
commit 8346be7882

View file

@ -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;
}