unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs@kosowsky.org, 15648@debbugs.gnu.org
Subject: bug#15648: 24.2.50; gnutls SSL connection to IMAP server causes emacs to crash completely
Date: Mon, 04 Nov 2013 11:44:41 -0500	[thread overview]
Message-ID: <8738ncru9y.fsf@flea.lifelogs.com> (raw)
In-Reply-To: <83a9hxgpt1.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 25 Oct 2013 21:37:14 +0300")

On Fri, 25 Oct 2013 21:37:14 +0300 Eli Zaretskii <eliz@gnu.org> wrote: 

>> From: Ted Zlatanov <tzz@lifelogs.com>
>> Cc: emacs@kosowsky.org,  15648@debbugs.gnu.org
>> Date: Fri, 25 Oct 2013 11:38:05 -0400
>> 
EZ> If so, perhaps the problem is that we leave the process object
EZ> marked as a GnuTLS process, but with a NULL state?  Should we remove
EZ> the mark, or maybe delete the process object in gnutls-negotiate?
>> 
>> I would abort with a message like any other error.

EZ> Maybe you should install a change that does that, and see if it solves
EZ> the problem.

You mean like this?  Should I have a special check for "gnutls_p is set
but gnutls_state is NULL"?

=== modified file 'src/process.c'
--- src/process.c       2013-11-04 06:09:03 +0000
+++ src/process.c       2013-11-04 16:43:26 +0000
@@ -4609,7 +4609,7 @@
                      {
                        struct Lisp_Process *p =
                          XPROCESS (chan_process[channel]);
-                       if (p && p->gnutls_p && p->infd
+                       if (p && p->gnutls_p && p->gnutls_state && p->infd
                            && ((emacs_gnutls_record_check_pending
                                 (p->gnutls_state))
                                > 0))
@@ -4623,6 +4623,7 @@
                {
                  /* Check this specific channel. */
                  if (wait_proc->gnutls_p /* Check for valid process.  */
+                      && p->gnutls_state
                      /* Do we have pending data?  */
                      && ((emacs_gnutls_record_check_pending
                           (wait_proc->gnutls_state))
@@ -5004,7 +5005,7 @@
          proc_buffered_char[channel] = -1;
        }
 #ifdef HAVE_GNUTLS
-      if (p->gnutls_p)
+      if (p->gnutls_p && p->gnutls_state)
        nbytes = emacs_gnutls_read (p, chars + carryover + buffered,
                                    readmax - buffered);
       else
@@ -5498,7 +5499,7 @@
 #endif
            {
 #ifdef HAVE_GNUTLS
-             if (p->gnutls_p)
+             if (p->gnutls_p && p->gnutls_state)
                written = emacs_gnutls_write (p, cur_buf, cur_len);
              else
 #endif

EZ> We _begin_ by setting gnutls_state to NULL.  What could possibly
EZ> happen is that we somehow let the process object with a NULL state
EZ> escape from the initialization step, and then
EZ> wait_reading_process_output stumbles on it and tries to use it,
EZ> because the gnutls_p flag is also set right at the beginning.

EZ> How about if we set the gnutls_p flag only when the whole
EZ> initialization succeeds completely?  It's only then that the process
EZ> is ready to be used in conjunction with GnuTLS, isn't it?

You're absolutely right.  Can you check if this patch is good?  It looks
OK to me.

Thank you very much for the guidance.

Ted

=== modified file 'src/gnutls.c'
--- src/gnutls.c        2013-11-04 06:09:03 +0000
+++ src/gnutls.c        2013-11-04 16:36:18 +0000
@@ -810,7 +822,6 @@
   c_hostname = SSDATA (hostname);
 
   state = XPROCESS (proc)->gnutls_state;
-  XPROCESS (proc)->gnutls_p = 1;
 
   if (TYPE_RANGED_INTEGERP (int, loglevel))
     {
@@ -833,7 +844,6 @@
   emacs_gnutls_deinit (proc);
 
   /* Mark PROC as a GnuTLS process.  */
-  XPROCESS (proc)->gnutls_p = 1;
   XPROCESS (proc)->gnutls_state = NULL;
   XPROCESS (proc)->gnutls_x509_cred = NULL;
   XPROCESS (proc)->gnutls_anon_cred = NULL;
@@ -1093,6 +1103,9 @@
       fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
     }
 
+  // Only set this flag if the whole initialization succeeded.
+  XPROCESS (proc)->gnutls_p = 1;
+
   return gnutls_make_error (ret);
 }






  parent reply	other threads:[~2013-11-04 16:44 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 18:29 bug#15648: 24.2.50; gnutls SSL connection to IMAP server causes emacs to crash completely emacs
2013-10-18 19:38 ` Glenn Morris
2013-10-20 20:24   ` emacs
2013-10-21 14:22   ` bug#15648: 24.2.50; gnutls SSL connection to IMAP server causes emacs to crash completely, " Ted Zlatanov
2013-10-21 19:30     ` emacs
2013-10-22 13:27       ` Ted Zlatanov
2013-10-22 15:23         ` emacs
2013-10-22 15:41           ` emacs
2013-10-22 19:10             ` emacs
2013-10-22 20:06               ` Ted Zlatanov
2013-10-22 20:22                 ` emacs
2013-10-22 20:34                   ` Eli Zaretskii
2013-10-22 22:27               ` emacs
2013-10-23  2:51                 ` Eli Zaretskii
2013-10-23  4:17                 ` emacs
2013-10-23 14:52                   ` Ted Zlatanov
2013-10-23 17:25                     ` emacs
2013-10-23 18:07                       ` Eli Zaretskii
2013-10-23 18:58                         ` Ted Zlatanov
2013-10-23 23:45                           ` emacs
2013-10-24  0:13                             ` emacs
2013-10-24 10:59                             ` Ted Zlatanov
2013-10-24 14:10                               ` emacs
2013-10-24 15:48                                 ` Ted Zlatanov
2013-10-24 17:02                                   ` emacs
2013-10-24 17:57                                 ` Stefan Monnier
2013-10-24 18:42                                   ` emacs
2013-10-25  0:59                                     ` Stefan Monnier
2013-10-25 13:59                                       ` emacs
2013-10-26  1:52                                         ` Stefan Monnier
2013-10-29  5:13                                           ` emacs
2013-11-03 11:42                                           ` Ted Zlatanov
2013-11-03 15:12                                             ` emacs
2013-11-03 17:32                                               ` Eli Zaretskii
2013-11-03 19:12                                                 ` emacs
2013-11-04 16:28                                                 ` Ted Zlatanov
2013-11-04 16:58                                                   ` Eli Zaretskii
2013-11-11 19:12                                                     ` emacs
2013-11-11 19:42                                                       ` Ted Zlatanov
2013-11-11 20:00                                                         ` emacs
2013-11-11 20:00                                                         ` Achim Gratz
2013-11-11 23:58                                                           ` Ted Zlatanov
2013-11-12  0:45                                                             ` emacs
2013-11-11 20:06                                                       ` Eli Zaretskii
2013-11-11 21:53                                                         ` emacs
2013-11-12  3:56                                                           ` Eli Zaretskii
2013-11-12 15:19                                                             ` emacs
2013-11-12 17:42                                                               ` Eli Zaretskii
     [not found]                                                               ` <<83ppq51pq8.fsf@gnu.org>
2013-11-12 18:08                                                                 ` Drew Adams
2013-11-03 21:37                                             ` Stefan Monnier
2013-10-23 15:16                   ` bug#15648: 24.2.50; gnutls SSL connection to IMAP server causes emacs to crash completely, " Eli Zaretskii
2013-10-23 17:12                     ` emacs
2013-10-23 18:00                       ` Eli Zaretskii
2013-10-23 19:49                         ` emacs
2013-10-24  2:46                           ` Eli Zaretskii
2013-10-25  3:17                         ` emacs
2013-10-25 14:09                           ` Eli Zaretskii
2013-10-25 15:38                             ` Ted Zlatanov
2013-10-25 18:37                               ` Eli Zaretskii
2013-11-03 17:30                                 ` Eli Zaretskii
2013-11-04 16:44                                 ` Ted Zlatanov [this message]
2013-11-04 17:06                                   ` Eli Zaretskii
2013-11-04 18:05                                     ` Ted Zlatanov
2013-11-04 22:14                                       ` emacs
2013-11-05  2:30                                         ` Ted Zlatanov
2013-11-05 23:11                                           ` emacs
2013-11-05 23:16                                             ` Alp Aker
2013-11-05 23:54                                               ` emacs
2013-11-11 15:53                                                 ` Ted Zlatanov
2013-11-11 19:40                                                   ` emacs
2013-11-11 20:11                                                     ` Eli Zaretskii
2013-11-11 21:56                                                       ` emacs
2013-11-12  3:58                                                         ` Eli Zaretskii
2013-11-12 15:23                                                           ` emacs
2013-11-06  3:51                                             ` Eli Zaretskii
2013-11-06  5:45                                               ` emacs
2013-10-22 15:43         ` bug#15648: 24.2.50; gnutls SSL connection to IMAP server causes emacs to crash completely, " Eli Zaretskii
2013-10-22 20:03           ` Ted Zlatanov
2013-10-22 20:35           ` Andy Moreton
2013-10-22 20:45             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738ncru9y.fsf@flea.lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=15648@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs@kosowsky.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).