Bug in status stream
Dmitri E. Soloviev
dmitris at interlog.com
Mon Jun 14 15:33:30 CEST 1999
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello, All:
This could be mentioned on the list earlier - I didn't
check all archives, but anyway this bug broke GnomePGP
interface. The data that is usually sent via status fd
can be ignored (thrown away without warning) if file
descriptor is not initialized yet. As it happens, we send
the shared memory information as soon as we get it - and
this [very important] data gets discarded.
Not going into gory details of when and who sends data
via status fd I added a little queuing mechanism to the
procedure write_status_text() so even if some data gets sent
too early it will be stored and sent later when another text
comes and file descriptor is already initialized.
This solution may be more complicated than figuring out the
synchronization between parts of the program - but I think
it's better to minimize dependencies between modules, esp.
in time-related matters.
As a side note, this fixed last serious bug in GnomePGP 0.4,
so I may release it in few days.
Thanks,
Dmitri
PGP keys at http://www.interlog.com/~dmitris
patch for the file gnupg-0.9.7/g10/status.c:
20a21
> #include <assert.h>
70a72,82
> /*
> * write_status_text()
> *
> * Procedure prefixes the 'text' message with specified word
> * and writes combined string into status_fd filedesc. If
> * the file descriptor is not yet available it queues data
> * until it becomes available at some later time.
> *
> * History:
> * 14-Jun-99 Added queuing.
> */
73a86,91
> struct queued_s {
> char *text;
> int no;
> struct queued_s *next;
> };
> static struct queued_s *qp = NULL;
74a93
> int text_len;
76,77c95,148
< if( fd == -1 )
< return; /* not enabled */
- ----
> if (text == NULL)
> return;
>
> text_len = strlen(text);
> if (text_len <= 0)
> return;
>
> if( fd == -1 ) { /* not enabled yet */
> /*
> * Must queue this request to print it later.
> */
> struct queued_s *new_q;
> new_q = m_alloc(sizeof(struct queued_s));
> assert(new_q != NULL);
> memset(new_q, 0, sizeof(struct queued_s));
> new_q->no = no;
> new_q->text = strdup(text);
> assert(new_q->text != NULL);
>
> /* Insert new element to the head of the list */
> new_q->next = qp;
> qp = new_q;
> return;
> }
>
> /*
> * If we have something queued, flush the queue first.
> * We queued elements in reverse order!
> */
> if (qp != NULL) {
> struct queued_s *queue, *q;
>
> /*
> * Invert, move queue from static 'qp' to local 'queue'
> */
> for (queue = NULL, q = qp; q != NULL;) {
> struct queued_s *q_next = q->next;
> q->next = queue;
> queue = q;
> q = q_next;
> }
> qp = NULL;
> /*
> * Now recursive calls of write_status_text() won't see 'pq'
> */
> for (q = queue; q != NULL;) {
> struct queued_s *q_next = q->next;
>
> write_status_text(q->no, q->text);
> free(q->text); /* Was allocated with strdup() */
> m_free(q); /* Was allocated with m_alloc() */
> q = q_next;
> }
> }
122c193
< write( fd, text, strlen(text) );
- ----
> write( fd, text, text_len );
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v0.9.7 (GNU/Linux)
Comment: GnomePGP version 0.4
iD8DBQE3ZUlP6jvttLEEo6ERAoHAAJ4l6dMaTngKm514E8JNgZeFmXVslwCg+lTD
7sg6JO6xX8MdeWjFeWmCt9U=
=ndi2
-----END PGP SIGNATURE-----
More information about the Gnupg-devel
mailing list