Nmap Development mailing list archives

Re: [PATCH] gcc warnings on *d2i() calls in ncat_ssl.c


From: David Fifield <david () bamsoftware com>
Date: Tue, 21 Jul 2009 19:01:13 -0600

On Mon, Jul 20, 2009 at 04:02:56AM +0400, Solar Designer wrote:
Attached is a patch for:

ncat_ssl.c:134: warning: passing arg 2 of `ASN1_item_d2i' from incompatible pointer type
ncat_ssl.c:138: warning: passing arg 2 of pointer to function from incompatible pointer type

 #if (OPENSSL_VERSION_NUMBER > 0x00907000L)
     if (method->it != NULL) {
         ext_str = ASN1_item_d2i(NULL,
-            (const unsigned char **) &ext->value->data,
+            (unsigned char **) &ext->value->data,
             ext->value->length, ASN1_ITEM_ptr(method->it));
     } else {
         ext_str = method->d2i(NULL,
-            (const unsigned char **) &ext->value->data,
+            (unsigned char **) &ext->value->data,
             ext->value->length);
     }
 #else

OpenSSL 0.9.7m declares ASN1_item_d2i() without "const" for the second
argument, but even if a newer version of OpenSSL has "const" there, this
patch should not produce a warning.  The "data" field is unlikely to
ever have "const" on it, because of the generic use of the struct type.

Hmm, no luck. With OpenSSL 0.9.8k 25 Mar 2009 I have in openssl/asn1.h

ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it);

Compiling without const gives me

ncat_ssl.c:221: warning: passing argument 2 of ‘ASN1_item_d2i’ from incompatible pointer type
/usr/include/openssl/asn1.h:1071: note: expected ‘const unsigned char **’ but argument is of type ‘unsigned char **’
ncat_ssl.c:225: warning: passing argument 2 of ‘method->d2i’ from incompatible pointer type
ncat_ssl.c:225: note: expected ‘const unsigned char **’ but argument is of type ‘unsigned char **’

Any ideas?

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: