aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--pasta.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pasta.c b/pasta.c
index 4cd58fd..5ef678d 100644
--- a/pasta.c
+++ b/pasta.c
@@ -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);
}