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 ee0c1b56d2b99a521eb29d533e8bcaf03a246f1a..54d9851bf661c9108e871f98db268bb486d7410a 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 @@ -194,7 +194,7 @@ void FileWatcher::ReadNotifyEvent(WatcherCallback callback) while (((len = read(notifyFd_, &buf, sizeof(buf))) < 0) && (errno == EINTR)) {}; while (index < len) { event = reinterpret_cast(buf + index); - if (sizeof(struct inotify_event) > (len - index)) { + if ((len - index) < sizeof(struct inotify_event)) { HILOGE("out of bounds access, len:%{public}d, index: %{public}d, inotify: %{public}zu", len, index, sizeof(struct inotify_event)); break;