]>
Commit | Line | Data |
---|---|---|
f3c0393d | 1 | diff -ur tcp_wrappers_7.6/rfc931.c tcp_wrappers_7.6.alarm/rfc931.c |
f302f894 JR |
2 | --- tcp_wrappers_7.6/rfc931.c Tue May 1 23:14:34 2001 |
3 | +++ tcp_wrappers_7.6.alarm/rfc931.c Tue May 1 23:13:56 2001 | |
f3c0393d JR |
4 | @@ -20,7 +20,6 @@ |
5 | #include <sys/types.h> | |
6 | #include <sys/socket.h> | |
7 | #include <netinet/in.h> | |
8 | -#include <setjmp.h> | |
9 | #include <signal.h> | |
10 | #include <string.h> | |
11 | ||
f302f894 | 12 | @@ -33,7 +32,8 @@ |
f3c0393d JR |
13 | |
14 | int rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */ | |
15 | ||
4d44a2fc | 16 | -static jmp_buf timebuf; |
f3c0393d | 17 | +struct sigaction oldact; |
f302f894 | 18 | +int restored = 0; |
f3c0393d JR |
19 | |
20 | /* fsocket - open stdio stream on top of socket */ | |
21 | ||
f302f894 | 22 | @@ -59,10 +59,10 @@ |
f3c0393d JR |
23 | |
24 | /* timeout - handle timeouts */ | |
25 | ||
26 | -static void timeout(sig) | |
27 | -int sig; | |
28 | +static void timeout(int signum) | |
29 | { | |
4d44a2fc | 30 | - longjmp(timebuf, sig); |
f3c0393d | 31 | + sigaction(SIGALRM,&oldact,NULL); |
f302f894 | 32 | + restored = 1; |
f3c0393d JR |
33 | } |
34 | ||
35 | /* rfc931 - return remote user name, given socket structures */ | |
f302f894 | 36 | @@ -92,6 +92,8 @@ |
92de6627 JR |
37 | char *cp; |
38 | char *result = unknown; | |
39 | FILE *fp; | |
40 | + int old_alarm; | |
f3c0393d | 41 | + struct sigaction act; |
92de6627 JR |
42 | |
43 | #ifdef INET6 | |
44 | /* address family must be the same */ | |
f302f894 | 45 | @@ -133,9 +135,18 @@ |
f3c0393d JR |
46 | * Set up a timer so we won't get stuck while waiting for the server. |
47 | */ | |
92de6627 | 48 | |
4d44a2fc | 49 | - if (setjmp(timebuf) == 0) { |
f3c0393d | 50 | - signal(SIGALRM, timeout); |
92de6627 | 51 | - alarm(rfc931_timeout); |
f3c0393d JR |
52 | + act.sa_handler = timeout; |
53 | + sigemptyset(&act.sa_mask); | |
54 | + act.sa_flags = 0; | |
55 | +#ifdef SA_INTERRUPT | |
56 | + act.sa_flags |= SA_INTERRUPT; | |
57 | +#endif | |
58 | + sigaction(SIGALRM,&act,&oldact); | |
f302f894 | 59 | + restored = 0; |
f3c0393d JR |
60 | +#ifdef HAVE_SIGINTERRUPT |
61 | + siginterrupt(SIGALRM,1); | |
62 | +#endif | |
63 | + old_alarm = alarm(rfc931_timeout); | |
92de6627 JR |
64 | |
65 | /* | |
66 | * Bind the local and remote ends of the query socket to the same | |
f302f894 | 67 | @@ -221,8 +232,11 @@ |
92de6627 JR |
68 | result = user; |
69 | } | |
70 | } | |
71 | - alarm(0); | |
f302f894 JR |
72 | + if (!restored) { |
73 | + sigaction(SIGALRM,&oldact,NULL); | |
74 | + restored = 1; | |
75 | } | |
f3c0393d | 76 | + alarm(old_alarm); |
92de6627 JR |
77 | fclose(fp); |
78 | } | |
f3c0393d | 79 | STRN_CPY(dest, result, STRING_LENGTH); |