From: Yu Watanabe Date: Thu, 1 Aug 2024 02:50:53 +0000 (+0900) Subject: vmspawn: check overflow earlier X-Git-Tag: v257-rc1~776^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a30ac8d52cba121c3e28dcc2a01767f639bff665;p=thirdparty%2Fsystemd.git vmspawn: check overflow earlier Follow-up for 862c68a914ab4561d83875e58e05dcf65cb4a551. Fixes CID#1550749. --- 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 */