restore_sigalarm 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. diff -ruN tcp_wrappers_7.6.orig/rfc931.c tcp_wrappers_7.6/rfc931.c
  2. --- tcp_wrappers_7.6.orig/rfc931.c 2004-08-29 18:40:08.000000000 +0200
  3. +++ tcp_wrappers_7.6/rfc931.c 2004-08-29 18:40:02.000000000 +0200
  4. @@ -92,6 +92,8 @@
  5. char *cp;
  6. char *result = unknown;
  7. FILE *fp;
  8. + unsigned saved_timeout;
  9. + struct sigaction nact, oact;
  10. #ifdef INET6
  11. /* address family must be the same */
  12. @@ -134,7 +136,12 @@
  13. */
  14. if (setjmp(timebuf) == 0) {
  15. - signal(SIGALRM, timeout);
  16. + /* Save SIGALRM timer and handler. Sudheer Abdul-Salam, SUN. */
  17. + saved_timeout = alarm(0);
  18. + nact.sa_handler = timeout;
  19. + nact.sa_flags = 0;
  20. + (void) sigemptyset(&nact.sa_mask);
  21. + (void) sigaction(SIGALRM, &nact, &oact);
  22. alarm(rfc931_timeout);
  23. /*
  24. @@ -223,6 +230,10 @@
  25. }
  26. alarm(0);
  27. }
  28. + /* Restore SIGALRM timer and handler. Sudheer Abdul-Salam, SUN. */
  29. + (void) sigaction(SIGALRM, &oact, NULL);
  30. + if (saved_timeout > 0)
  31. + alarm(saved_timeout);
  32. fclose(fp);
  33. }
  34. STRN_CPY(dest, result, STRING_LENGTH);