Skip to content

Commit 41272a9

Browse files
Fix vtrnd pci_vtrnd_notify uninitialized memory use (GHSL-2021-056)
Signed-off-by: Frederic Dalleau <frederic.dalleau@docker.com>
1 parent 451558f commit 41272a9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/pci_virtio_rnd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
100100
{
101101
struct iovec iov;
102102
struct pci_vtrnd_softc *sc;
103-
int len;
103+
int len, n;
104104
uint16_t idx;
105105

106106
sc = vsc;
@@ -111,7 +111,11 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
111111
}
112112

113113
while (vq_has_descs(vq)) {
114-
vq_getchain(vq, &idx, &iov, 1, NULL);
114+
n = vq_getchain(vq, &idx, &iov, 1, NULL);
115+
if (n < 0) {
116+
fprintf(stderr, "vtrnd: vtrnd_notify(): n %d\r\n", n);
117+
return;
118+
}
115119

116120
len = (int) read(sc->vrsc_fd, iov.iov_base, iov.iov_len);
117121

0 commit comments

Comments
 (0)