OpenSSH -current fails regression on Solaris 8, sshd dumps core

Sam Reynolds cloud at chool.com
Mon Sep 23 07:59:30 EST 2002


On Sat, Sep 21, 2002 at 01:20:19PM -0500, Sam Reynolds wrote:

 >> Hi,  I believe the behavior of passing NULL to %s is undefined.


 >dunno about that either way


 >> NULL can be (but isn't necessarily) a macro expanding to
 >> (void*)0


 >No, it isn't.  NULL is guaranteed to be a macro expanding to an
 >"unadorned 0".
I don't believe in C such a guarantee is given.
7.17.3 in C99 says:
"... NULL which expands to an implementation-defined null
pointer constant..."
6.23.2.3.3 explains that a null pointer constant is:
"An integer constant expression with the value 0, or such
an expression cast to type void *"

 >> and since sprintf is a variadic function, one would
 >> need an explicit cast to the appropriate type.


 >No, one doesn't.  A variadic function interprets pointers based on the
 >format string, not based on the type given to the compiler.

One does for two reasons. The first being a situation where my format
string is input from the user, clearly the compiler can't know what the
args are going to be at compile time. Second, if I write my own
variadic function the compiler will not know what the arguments to
my function are if I don't explicitly cast them (if they are void*).

 >/fc
Hope this helps,

-- 
Sam Reynolds
cloud at chool.com




More information about the openssh-unix-dev mailing list