]> git.pld-linux.org Git - packages/tcp_wrappers.git/blob - tcp_wrappers-alarm.patch
- rediffed
[packages/tcp_wrappers.git] / tcp_wrappers-alarm.patch
1 diff -ur tcp_wrappers_7.6/rfc931.c tcp_wrappers_7.6.alarm/rfc931.c
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
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  
12 @@ -33,7 +32,8 @@
13  
14  int     rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */
15  
16 -static jmp_buf timebuf;
17 +struct sigaction oldact;
18 +int    restored = 0;
19  
20  /* fsocket - open stdio stream on top of socket */
21  
22 @@ -59,10 +59,10 @@
23  
24  /* timeout - handle timeouts */
25  
26 -static void timeout(sig)
27 -int     sig;
28 +static void timeout(int signum)
29  {
30 -    longjmp(timebuf, sig);
31 +       sigaction(SIGALRM,&oldact,NULL);
32 +       restored = 1;
33  }
34  
35  /* rfc931 - return remote user name, given socket structures */
36 @@ -92,6 +92,8 @@
37      char   *cp;
38      char   *result = unknown;
39      FILE   *fp;
40 +    int    old_alarm;
41 +    struct sigaction act;
42  
43  #ifdef INET6
44      /* address family must be the same */
45 @@ -133,9 +135,18 @@
46          * Set up a timer so we won't get stuck while waiting for the server.
47          */
48  
49 -       if (setjmp(timebuf) == 0) {
50 -           signal(SIGALRM, timeout);
51 -           alarm(rfc931_timeout);
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);
59 +       restored = 0;
60 +#ifdef HAVE_SIGINTERRUPT
61 +       siginterrupt(SIGALRM,1);
62 +#endif
63 +       old_alarm = alarm(rfc931_timeout);
64  
65             /*
66              * Bind the local and remote ends of the query socket to the same
67 @@ -221,8 +232,11 @@
68                     result = user;
69                 }
70             }
71 -           alarm(0);
72 +       if (!restored) {
73 +               sigaction(SIGALRM,&oldact,NULL);
74 +               restored = 1;
75         }
76 +       alarm(old_alarm);
77         fclose(fp);
78      }
79      STRN_CPY(dest, result, STRING_LENGTH);
This page took 0.234087 seconds and 3 git commands to generate.