From cb8a9d74a07da5ea83cbad6f8402c14710689df2 Mon Sep 17 00:00:00 2001 From: shihchienc Date: Thu, 11 Apr 2024 06:16:07 +0000 Subject: [PATCH] [Thread] make sure buffer size is enough inotify event size is dynamic, we need to make sure read would not return error when having inotify event. Bug: 333829392 Test: manual check `Invalid argument` error won't happen Change-Id: I3cac8d1519659c6b1b53c1d41013818adab876c7 --- threadnetwork/aidl/default/socket_interface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/threadnetwork/aidl/default/socket_interface.cpp b/threadnetwork/aidl/default/socket_interface.cpp index 7bdf39ad5d..0544502ea9 100644 --- a/threadnetwork/aidl/default/socket_interface.cpp +++ b/threadnetwork/aidl/default/socket_interface.cpp @@ -23,6 +23,7 @@ #include "socket_interface.hpp" #include +#include #include #include #include @@ -273,7 +274,7 @@ void SocketInterface::WaitForSocketFileCreated(const char* aPath) { } if (FD_ISSET(inotifyFd, &fds)) { - char buffer[sizeof(struct inotify_event)]; + char buffer[sizeof(struct inotify_event) + NAME_MAX + 1]; ssize_t bytesRead = read(inotifyFd, buffer, sizeof(buffer)); VerifyOrDie(bytesRead >= 0, OT_EXIT_ERROR_ERRNO);