vmspawn: check overflow earlier

Follow-up for 862c68a914.
Fixes CID#1550749.
This commit is contained in:
Yu Watanabe
2024-08-01 11:50:53 +09:00
parent 96bf7e1f3b
commit a30ac8d52c

View File

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