aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-11-01 20:57:28 +0100
committerLars Ingebrigtsen2016-11-01 20:57:28 +0100
commit126c879df42f741fe486236aea538290a8c2ed64 (patch)
treecb41558f2146c3aa2f948f14a749f1e25472e7a1 /src/process.c
parentc3640fcc96ed80368209c73d7ac9a0f0d1833d93 (diff)
downloademacs-126c879df42f741fe486236aea538290a8c2ed64.tar.gz
emacs-126c879df42f741fe486236aea538290a8c2ed64.zip
Don't segfault on timed-out TLS connections
* src/process.c (finish_after_tls_connection): Check that the file descriptor is still alive before proceeding (bug#24811). Also clean up the code slightly.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c
index 8cf045ca9c2..d27b57d560f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3094,19 +3094,24 @@ finish_after_tls_connection (Lisp_Object proc)
3094 build_string ("The Network Security Manager stopped the connections"))); 3094 build_string ("The Network Security Manager stopped the connections")));
3095 deactivate_process (proc); 3095 deactivate_process (proc);
3096 } 3096 }
3097 else 3097 else if (p->outfd < 0)
3098 { 3098 {
3099 /* If we cleared the connection wait mask before we did 3099 /* The counterparty may have closed the connection (especially
3100 the TLS setup, then we have to say that the process 3100 if the NSM promt above take a long time), so recheck the file
3101 is finally "open" here. */ 3101 descriptor here. */
3102 if (! FD_ISSET (p->outfd, &connect_wait_mask)) 3102 pset_status (p, Qfailed);
3103 { 3103 deactivate_process (proc);
3104 pset_status (p, Qrun); 3104 }
3105 /* Execute the sentinel here. If we had relied on 3105 else if (! FD_ISSET (p->outfd, &connect_wait_mask))
3106 status_notify to do it later, it will read input 3106 {
3107 from the process before calling the sentinel. */ 3107 /* If we cleared the connection wait mask before we did the TLS
3108 exec_sentinel (proc, build_string ("open\n")); 3108 setup, then we have to say that the process is finally "open"
3109 } 3109 here. */
3110 pset_status (p, Qrun);
3111 /* Execute the sentinel here. If we had relied on status_notify
3112 to do it later, it will read input from the process before
3113 calling the sentinel. */
3114 exec_sentinel (proc, build_string ("open\n"));
3110 } 3115 }
3111} 3116}
3112#endif 3117#endif