Skip to content

Commit cd75b08

Browse files
committed
Don't work out buffers on a truncated header.
1 parent a3ce698 commit cd75b08

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/privsep-root.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ ps_root_readerrorcb(struct psr_ctx *psr_ctx)
107107

108108
/* After this point, we MUST do another recvmsg even on a failure
109109
* to remove the message after peeking. */
110-
if ((size_t)len < sizeof(*psr_error))
111-
goto recv;
110+
if ((size_t)len < sizeof(*psr_error)) {
111+
/* We can't use the header to work out buffers, so
112+
* remove the message and bail. */
113+
(void)recvmsg(fd, &msg, MSG_WAITALL);
114+
PSR_ERROR(EINVAL);
115+
}
112116

113117
if (psr_ctx->psr_usemdata &&
114118
psr_error->psr_datalen > psr_ctx->psr_mdatalen)
@@ -139,7 +143,6 @@ ps_root_readerrorcb(struct psr_ctx *psr_ctx)
139143
iov[1].iov_len = psr_error->psr_datalen;
140144
}
141145

142-
recv:
143146
len = recvmsg(fd, &msg, MSG_WAITALL);
144147
if (len == -1)
145148
PSR_ERROR(errno);

0 commit comments

Comments
 (0)