s3: Fix a 64-bit BUG
authorVolker Lendecke <vl@samba.org>
Sat, 2 Oct 2010 09:13:34 +0000 (11:13 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 2 Oct 2010 09:17:49 +0000 (11:17 +0200)
Quick explanation why this is a problem:

It is not safe to pass a pointer to a uint32_t into a routine that expects
a size_t *. The routine that this pointer is passed to has no chance to find
out that in reality it was passed a pointer to a uint32_t. On platforms where
sizeof(size_t)==8, we get a nice overwrite of a stack area that should not
be overwritten.

As this happens over an over again: Does someone know a means to make gcc
stop with an error in this case?

Volker

lib/util/asn1.c

index c4923343e259068e507021d182507787693282bf..7e37fbc91bd42d20f66662c9c560d20750c159e5 100644 (file)
@@ -1011,7 +1011,7 @@ NTSTATUS asn1_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size)
 NTSTATUS asn1_peek_full_tag(DATA_BLOB blob, uint8_t tag, size_t *packet_size)
 {
        struct asn1_data asn1;
-       uint32_t size;
+       size_t size;
        bool ok;
 
        ZERO_STRUCT(asn1);