Fix arping hang if SIGALRM is blocked (#1085971)

This commit is contained in:
Jan Synacek 2014-04-11 09:14:01 +02:00
parent e596563bac
commit f47c6dffe6
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,32 @@
Author: Rui Prior <rprior@dcc.fc.up.pt>
Resolves: #1085971
--- iputils-s20121221-orig/arping.c 2014-04-10 15:41:29.158243387 +0100
+++ iputils-s20121221-new/arping.c 2014-04-10 16:02:06.000000000 +0100
@@ -1215,16 +1215,22 @@ main(int argc, char **argv)
socklen_t alen = sizeof(from);
int cc;
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGALRM);
+ sigaddset(&sset, SIGINT);
+ /* Unblock SIGALRM so that the previously called alarm()
+ * can prevent recvfrom from blocking forever in case the
+ * inherited procmask is blocking SIGALRM and no packet
+ * is received. */
+ sigprocmask(SIG_UNBLOCK, &sset, &osset);
+
if ((cc = recvfrom(s, packet, sizeof(packet), 0,
(struct sockaddr *)&from, &alen)) < 0) {
perror("arping: recvfrom");
continue;
}
- sigemptyset(&sset);
- sigaddset(&sset, SIGALRM);
- sigaddset(&sset, SIGINT);
- sigprocmask(SIG_BLOCK, &sset, &osset);
+ sigprocmask(SIG_BLOCK, &sset, NULL);
recv_pack(packet, cc, (struct sockaddr_ll *)&from);
sigprocmask(SIG_SETMASK, &osset, NULL);
}

View File

@ -3,7 +3,7 @@
Summary: Network monitoring tools including ping
Name: iputils
Version: 20121221
Release: 9%{?dist}
Release: 10%{?dist}
# some parts are under the original BSD (ping.c)
# some are under GPLv2+ (tracepath.c)
License: BSD and GPLv2+
@ -19,6 +19,7 @@ Patch0: iputils-20020927-rh.patch
Patch1: iputils-ifenslave.patch
Patch2: iputils-20121221-floodlocale.patch
Patch3: iputils-20121221-eperm-flood.patch
Patch4: iputils-20121221-sigalrm-unblock.patch
BuildRequires: docbook-utils perl-SGMLSpm
BuildRequires: glibc-kernheaders >= 2.4-8.19
@ -60,6 +61,7 @@ Queries.
%patch1 -p1 -b .addr
%patch2 -p1 -b .floc
%patch3 -p1 -b .eperm
%patch4 -p1 -b .sigalrm
%build
%ifarch s390 s390x
@ -160,6 +162,9 @@ mv -f RELNOTES.tmp RELNOTES
%attr(644,root,root) %{_mandir}/man8/ninfod.8.gz
%changelog
* Fri Apr 11 2014 Jan Synáček <jsynacek@redhat.com> - 20121221-10
- Fix arping hang if SIGALRM is blocked (#1085971)
* Wed Mar 26 2014 Jan Synáček <jsynacek@redhat.com> - 20121221-9
- Fix message flood when EPERM is encountered in ping (#1061867)