diff options
| author | Aditya Merchant <adityamerchant08@gmail.com> | 2026-11-13 16:51:14 +0530 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-11-30 00:37:09 +0100 |
| commit | bb42edcc223ad40ee642004f83d2a62ebb47ae0b (patch) | |
| tree | e57acb3374e2dfb8120bce4f328319b47c12fc04 | |
| parent | f6d66985479641283059841b71966f84b5188890 (diff) | |
| download | passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar.gz passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar.bz2 passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar.lz passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar.xz passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.tar.zst passt-bb42edcc223ad40ee642004f83d2a62ebb47ae0b.zip | |
pasta: Terminate inotify buffer, skip nameless events in netns watch
In pasta_netns_quit_inotify_handler(), we compare the name of each event
we read with the base name of the namespace, but we don't make sure that
the buffer we read events into is zero-terminated. Events without a name,
such as the IN_IGNORED we get once the watch is removed, also have no
name to compare: for those, ev->name points past the end of the event.
Terminate the buffer, as wait_for_socket() in passt-repair does, and
skip events without a name.
Suggested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Aditya Merchant <adityamerchant08@gmail.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | pasta.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -537,10 +537,13 @@ void pasta_netns_quit_inotify_handler(const struct ctx *c, int inotify_fd) if ((n = read(inotify_fd, buf, sizeof(buf))) < (ssize_t)sizeof(*ev)) return; + /* cppcheck-suppress [negativeIndex, unmatchedSuppression] */ + buf[n - 1] = '\0'; for (p = buf; p < buf + n; p += sizeof(*ev) + ev->len) { ev = (const struct inotify_event *)p; - if (!strncmp(ev->name, c->netns_base, sizeof(c->netns_base))) { + if (ev->len && + !strncmp(ev->name, c->netns_base, sizeof(c->netns_base))) { info("Namespace %s is gone, exiting", c->netns_base); passt_exit(EXIT_SUCCESS); } |
