Your message dated Fri, 5 Jan 2007 22:38:39 +0100
with message-id <[EMAIL PROTECTED]>
and subject line old bugs
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--- Begin Message ---
Package: gnutls3
Version: 0.3.5-3.2
The function gnutls_malloc() which is defined in lib/gnutls_mem.c line 43
returns inapropriately aligned blocks to the caller. It takes a block that
is returned by malloc(), which is guaranteed to be apropriately aligned,
and returns that block offsetted by EXTRA_SIZE to the caller. Since
EXTRA_SIZE is 5, this breaks the assumption about alignment that
callers to gnutls_malloc() make and fails on architectures that care
about alignment.
Here is sample output from gdb running mutt on SPARC attempting to
open a mailbox using IMAP SSL. The problem occurs in _asn1_add_node()
right after the call to gnutls_malloc().
Program received signal SIGBUS, Bus error.
0x704779ac in _asn1_add_node () from /usr/lib/libgnutls.so.3
(gdb) bt
#0 0x704779ac in _asn1_add_node () from /usr/lib/libgnutls.so.3
#1 0x70478138 in asn1_create_tree () from /usr/lib/libgnutls.so.3
#2 0x704711c4 in gnutls_global_init () from /usr/lib/libgnutls.so.3
#3 0x70421a40 in _init () from /usr/lib/mutt/mutt_ssl_gnutls.so
#4 0x70421ab0 in mutt_gnutls_socket_setup ()
from /usr/lib/mutt/mutt_ssl_gnutls.so
#5 0x00085ff4 in mutt_gnutls_socket_setup ()
#6 0x0007d9a8 in mutt_conn_find ()
#7 0x00080ba4 in imap_conn_find ()
#8 0x00081068 in imap_open_mailbox ()
#9 0x0004b704 in mx_open_mailbox ()
#10 0x000434a8 in main ()
#11 0x700d7438 in __libc_start_main () from /lib/libc.so.6
Here is a patch.
-Phil
--- lib/gnutls_mem.c 2002/11/17 20:25:34 1.1
+++ lib/gnutls_mem.c 2002/11/17 20:44:18
@@ -32,12 +32,17 @@
#else
/* #define MALLOC_DEBUG */
-# define EXTRA_SIZE sizeof(size_t)+1
+struct gnutls_malloc_extra {
+ size_t ptrsize;
+ int secureflag;
+};
+#define EXTRA_SIZE sizeof(struct gnutls_malloc_extra) /* should be 8 -pkv */
+#define gnutls_extra(ptr) (((struct gnutls_malloc_extra *)(ptr))-1)
int _gnutls_is_secure_memory(const svoid * mem)
{
if (mem==NULL) return 0;
- return *((opaque *) mem - 1);
+ return gnutls_extra(mem)->secureflag;
}
void *gnutls_malloc(size_t size)
@@ -50,8 +55,9 @@
if (ret == NULL)
return ret;
- *((int *) ret) = size;
- ret[sizeof(size_t)] = 0; /* not secure */
+ ((struct gnutls_malloc_extra *)ret)->ptrsize = size;
+ ((struct gnutls_malloc_extra *)ret)->secureflag = 0;
+ /* not secure */
ret += EXTRA_SIZE;
@@ -67,7 +73,7 @@
void *gnutls_calloc(size_t nmemb, size_t size)
{
void *ret;
- ret = gnutls_malloc(size);
+ ret = gnutls_malloc(nmemb*size);
if (ret == NULL)
return ret;
@@ -83,7 +89,7 @@
if (_ptr == NULL)
return 0;
- return *((int *) ((opaque *) ptr - sizeof(size_t) - 1));
+ return gnutls_extra(_ptr)->ptrsize;
}
void *gnutls_realloc(void *_ptr, size_t size)
@@ -98,8 +104,9 @@
if (ret == NULL)
return ret;
- *((int *) ret) = size;
- ret[sizeof(size_t)] = 0; /* not secure */
+ ((struct gnutls_malloc_extra *)ret)->ptrsize = size;
+ ((struct gnutls_malloc_extra *)ret)->secureflag = 0;
+ /* not secure */
ret += EXTRA_SIZE;
@@ -149,7 +156,7 @@
if (ret == NULL)
return ret;
- *((opaque *) ret - 1) = 1; /* secure mem */
+ gnutls_extra(ret)->secureflag = 1; /* secure mem */
return ret;
@@ -158,7 +165,7 @@
svoid *gnutls_secure_calloc(size_t nmemb, size_t size)
{
svoid *ret;
- ret = gnutls_secure_malloc(size);
+ ret = gnutls_secure_malloc(nmemb*size);
if (ret == NULL)
return ret;
@@ -198,7 +205,7 @@
opaque* _ptr = ptr;
memset(ptr, 0, _gnutls_secure_ptr_size(ptr));
- *((opaque *) _ptr - 1) = 0; /* not secure mem */
+ gnutls_extra(ptr)->secureflag = 0; /* not secure mem */
gnutls_free(ptr);
}
--- End Message ---
--- Begin Message ---
I suppose these really old gnutls no longer apply. Please let me know
if I'm wrong.
--
Martin Michlmayr
http://www.cyrius.com/
--- End Message ---