diff --git a/interfaces/kits/cj/src/copy.cpp b/interfaces/kits/cj/src/copy.cpp index 5f9647e63afeb1ad15c4c8c3192848b0da981145..7cded9586d5a124fdf43abf19ccb58afe0b4266c 100644 --- a/interfaces/kits/cj/src/copy.cpp +++ b/interfaces/kits/cj/src/copy.cpp @@ -494,6 +494,9 @@ void CopyImpl::ReadNotifyEvent(std::shared_ptr infos) auto callback = GetRegisteredListener(infos); while (((len = read(infos->notifyFd, &buf, sizeof(buf))) < 0) && (errno == EINTR)) {} while (infos->run && index < len) { + if ((index + sizeof(struct inotify_event)) > len) { + break; + } event = reinterpret_cast(buf + index); auto [needContinue, errCode, needSend] = HandleProgress(event, infos, callback); if (!needContinue) {