unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: walter@pelissero.de
Cc: 10535@debbugs.gnu.org
Subject: bug#10535: 23.3; starttls-negotiate-gnutls erases random buffer
Date: Tue, 17 Jan 2012 18:11:15 -0500	[thread overview]
Message-ID: <5sr4yxq60c.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <20245.27412.138376.596455@scylla.home.lan>

Walter C. Pelissero wrote:

> starttls-negotiate-gnutls obliterates the contents of the second
> buffer in the buffers list.
>
> For instance a form like this may expose the bug:
>
> (jabber-starttls-connect '(:fsm jabber-connection :state :connecting :state-data (:send-function jabber-ssl-send :username "me" :server "jabme.de" :password "secret" :registerp nil :connection-type starttls :encrypted nil :network-server nil :port nil) :sleep 3 :deferred nil) "jabber.host" nil nil)
>
> I've noticed that the local variable `buffer' in
> starttls-negotiate-gnutls may contain a killed buffer, which I guessed
> it might be the source of the problem.

I didn't try to reproduce this (not having jabber installed), but
I don't see how that could be the source of any such issue. Eg:

(with-temp-buffer
  (setq foo (current-buffer)))

(with-current-buffer foo
  (insert "hi"))

does not insert "hi" in a random buffer, but stops with "(error
"Selecting deleted buffer")"

>  the following patch seems to fix the problem at least in starttls.
> The patch, despite it's length

(diff -w can be useful)

> , just checks that the buffer is still alive.

> !     (if (and buffer (buffer-live-p buffer))
> ! 	(with-current-buffer buffer

As shown above, a buffer that is not live should already cause an error,
so I don't see how adding a buffer-live-p test can help.

> In fact the following code erases the content of any writable buffer
> happening to be second in the buffers list:
>
> (let ((buffer (generate-new-buffer "foobar")))
>    (with-current-buffer buffer (kill-buffer buffer) (erase-buffer)))
>
> Although I don't know if the behaviour above is to be expected,

It is expected (and is not related to anything starttls-negotiate-gnutls
is doing AFAICS). The Elisp manual section on "Killing Buffers" cautions
about such usage.





  reply	other threads:[~2012-01-17 23:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-17 12:35 bug#10535: 23.3; starttls-negotiate-gnutls erases random buffer Walter C. Pelissero
2012-01-17 23:11 ` Glenn Morris [this message]
2012-01-18  8:56   ` Walter C. Pelissero
2012-01-18 18:07     ` Glenn Morris

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=5sr4yxq60c.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=10535@debbugs.gnu.org \
    --cc=walter@pelissero.de \
    /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).