From a30ac8d52cba121c3e28dcc2a01767f639bff665 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 1 Aug 2024 11:50:53 +0900 Subject: [PATCH] vmspawn: check overflow earlier Follow-up for 862c68a914ab4561d83875e58e05dcf65cb4a551. Fixes CID#1550749. --- src/vmspawn/vmspawn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index 8fad195abcd..030efbdb23f 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -626,10 +626,10 @@ static int read_vsock_notify(NotifyConnectionData *d, int fd) { if (n == 0) /* We hit EOF! Let's parse this */ break; - d->full += n; - - if (d->full >= sizeof(d->buffer)) + if ((size_t) n >= sizeof(d->buffer) - d->full) return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Received notify message exceeded maximum size."); + + d->full += n; } /* We reached EOF, now parse the thing */ -- 2.47.3