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 */