From e4f16eae6610d2d1895a7ee9d339ba22387e5f09 Mon Sep 17 00:00:00 2001 From: tianp Date: Fri, 12 Sep 2025 15:15:34 +0800 Subject: [PATCH] =?UTF-8?q?watcher=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp --- .../kits/js/src/mod_fs/class_watcher/watcher_entity.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/class_watcher/watcher_entity.cpp b/interfaces/kits/js/src/mod_fs/class_watcher/watcher_entity.cpp index 187683a0f..5a7878807 100644 --- a/interfaces/kits/js/src/mod_fs/class_watcher/watcher_entity.cpp +++ b/interfaces/kits/js/src/mod_fs/class_watcher/watcher_entity.cpp @@ -168,7 +168,6 @@ int FileWatcher::StopNotify(shared_ptr arg) lock_guard lock(readMutex_); if (!(closed_ && reading_)) { oldWd = inotify_rm_watch(notifyFd_, arg->wd); - HILOGE("rm watch failed, err: %{public}d", errno); } else { HILOGE("rm watch fail"); } @@ -195,14 +194,15 @@ void FileWatcher::ReadNotifyEvent(WatcherCallback callback) while (((len = read(notifyFd_, &buf, sizeof(buf))) < 0) && (errno == EINTR)) {}; while (index < len) { event = reinterpret_cast(buf + index); - if ((len - index) < sizeof(struct inotify_event)) { + if (sizeof(struct inotify_event) > (len - index)) { HILOGE("out of bounds access, len:%{public}d, index: %{public}d, inotify: %{public}zu", len, index, sizeof(struct inotify_event)); break; } - if (event->len > (static_cast(len - index - sizeof(struct inotify_event)))) { + if (static_cast(event->len) > + (static_cast(len - index - sizeof(struct inotify_event)))) { HILOGE("out of bounds access, index: %{public}d, inotify: %{public}zu, " - "event :%{public}u, len: %{public}d", + "event->len :%{public}u, len: %{public}d", index, sizeof(struct inotify_event), event->len, len); break; -- Gitee