diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-06 21:04:46 +0100 |
---|---|---|
committer | Skyler <skyler3665@gmail.com> | 2023-10-07 08:35:04 +0000 |
commit | 1f9c1885b9e212106761c68060a7af8d3cabc700 (patch) | |
tree | b874d1402315e5c09686071c263a57ccddb4f911 /wsd/COOLWSD.cpp | |
parent | remove stray libsimd.a (diff) | |
download | online-1f9c1885b9e212106761c68060a7af8d3cabc700.tar.gz online-1f9c1885b9e212106761c68060a7af8d3cabc700.zip |
cid#323357 silence String not null terminated
it's a good catch, but inotify man page says it can't happen
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I350f8fad2aa8308563ccb4f9f3ec9b7850a72fa7
Diffstat (limited to 'wsd/COOLWSD.cpp')
-rw-r--r-- | wsd/COOLWSD.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/wsd/COOLWSD.cpp b/wsd/COOLWSD.cpp index 3f128928d9..680509a827 100644 --- a/wsd/COOLWSD.cpp +++ b/wsd/COOLWSD.cpp @@ -1078,14 +1078,16 @@ void InotifySocket::handlePoll(SocketDisposition & /* disposition */, std::chron return; char buf[4096]; + + static_assert(sizeof(buf) >= sizeof(struct inotify_event) + NAME_MAX + 1, "see man 7 inotify"); + const struct inotify_event* event; - ssize_t len; LOG_TRC("InotifyPoll - Checking for config changes..."); while (true) { - len = read(getFD(), buf, sizeof(buf)); + ssize_t len = read(getFD(), buf, sizeof(buf)); if (len == -1 && errno != EAGAIN) { @@ -1101,6 +1103,8 @@ void InotifySocket::handlePoll(SocketDisposition & /* disposition */, std::chron if (len <= 0) break; + assert(buf[len - 1] == 0 && "see man 7 inotify"); + for (char* ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) { event = (const struct inotify_event*)ptr; |