Use MSG_WAITALL when receiving struct command_status over the Unix

domain socket since we no longer use datagrams.  This should avoid
the need to handle incomplete reads, though in theory it is still
possible.
This commit is contained in:
Todd C. Miller
2013-10-29 15:26:32 -06:00
parent abe0314e01
commit fd88ed42c8
2 changed files with 2 additions and 2 deletions

View File

@@ -208,7 +208,7 @@ backchannel_cb(int fd, int what, void *v)
debug_decl(backchannel_cb, SUDO_DEBUG_EXEC) debug_decl(backchannel_cb, SUDO_DEBUG_EXEC)
/* read child status */ /* read child status */
n = recv(fd, ec->cstat, sizeof(struct command_status), 0); n = recv(fd, ec->cstat, sizeof(struct command_status), MSG_WAITALL);
if (n != sizeof(struct command_status)) { if (n != sizeof(struct command_status)) {
if (n == -1) { if (n == -1) {
switch (errno) { switch (errno) {

View File

@@ -1141,7 +1141,7 @@ mon_backchannel_cb(int fd, int what, void *v)
debug_decl(mon_backchannel_cb, SUDO_DEBUG_EXEC); debug_decl(mon_backchannel_cb, SUDO_DEBUG_EXEC);
/* read command from backchannel, should be a signal */ /* read command from backchannel, should be a signal */
n = recv(fd, &cstmp, sizeof(cstmp), 0); n = recv(fd, &cstmp, sizeof(cstmp), MSG_WAITALL);
if (n != sizeof(cstmp)) { if (n != sizeof(cstmp)) {
if (n == -1) { if (n == -1) {
if (errno == EINTR || errno == EAGAIN) if (errno == EINTR || errno == EAGAIN)