diff options
author | Ulrich Drepper <drepper@gmail.com> | 2012-03-30 08:38:58 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2012-03-30 08:38:58 -0400 |
commit | 966977f1b72123bdd5187a60e9b50eaa70312d90 (patch) | |
tree | f95192360ad566fe589cb75e8fa562f8d90de6fd /resolv | |
parent | 8e6d108343c2f15d684b84fa48b73b23eb0e7c8b (diff) | |
download | glibc-966977f1b72123bdd5187a60e9b50eaa70312d90.tar.gz glibc-966977f1b72123bdd5187a60e9b50eaa70312d90.tar.xz glibc-966977f1b72123bdd5187a60e9b50eaa70312d90.zip |
Better error handling for sendmmsg use in res_send
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/res_send.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c index 968ede09fa..0a28cd784b 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -1132,22 +1132,23 @@ send_dg(res_state statp, int ndg = sendmmsg (pfd[0].fd, reqs, 2, MSG_NOSIGNAL); if (__builtin_expect (ndg == 2, 1)) { - assert (reqs[0].msg_len == buflen); - assert (reqs[1].msg_len == buflen2); + if (reqs[0].msg_len != buflen + || reqs[1].msg_len != buflen2) + goto fail_sendmmsg; pfd[0].events = POLLIN; nwritten += 2; } else if (ndg == 1 && reqs[0].msg_len == buflen) goto just_one; - else if (errno == EINTR || errno == EAGAIN) + else if (ndg < 0 && (errno == EINTR || errno == EAGAIN)) goto recompute_resend; else { #ifndef __ASSUME_SENDMMSG - if (have_sendmmsg == 0) + if (__builtin_expect (have_sendmmsg == 0, 0)) { - if (errno == ENOSYS) + if (ndg < 0 && errno == ENOSYS) { have_sendmmsg = -1; goto try_send; @@ -1156,6 +1157,7 @@ send_dg(res_state statp, } #endif + fail_sendmmsg: Perror(statp, stderr, "sendmmsg", errno); goto err_out; } |