Nmap Development mailing list archives

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


From: Solar Designer <solar () openwall com>
Date: Mon, 20 Jul 2009 04:02:56 +0400

Hi,

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

BTW, those typecasts are also potentially problematic as it relates to C
strict aliasing rules.  There are no warnings from gcc on that, but gcc
prints those "strict aliasing warnings" in _some_ cases only, depending
on the optimizer.  ...Oh, I've just realized that you build with
-fno-strict-aliasing, which should be avoiding the warnings too.  Yet
this does not fix the underlying problem, which may well bite you when
you build with a modern compiler other than gcc.

I have not reviewed this piece of code in sufficient context to
determine whether it is affected for real or not (is ext->value->data
read further in the same function? if so, an incorrect cached value may
potentially be used).

Since you're currently building with -fno-strict-aliasing, I suspect
that you have a lot of risky code elsewhere as well.  I suggest that you
do a test build without that option, then fix the bug (which is very
different from "fixing the warnings" - you need to review the code in
context and come up with a correct fix for each instance separately).
You can see a sample strict aliasing fix here:

http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/popa3d/popa3d/auth_pam.c.diff?r1=1.3;r2=1.4

IIRC, another valid approach is to use a union, but I prefer separate
variables.

Alexander

Attachment: nmap-5.00-owl-warnings.diff
Description:


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

Current thread: