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

Sam Reynolds cloud at chool.com
Tue Sep 24 23:02:55 EST 2002


On Sun, Sep 22, 2002 at 04:59:30PM -0500, Sam Reynolds wrote:

[snip]

 >>  >> 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.


 >In which case, how are you going to know what to cast to?
Oops, what I said there isn't true :)
What I intended to say was "The first being a situation where my format
string is input from the user, clearly the compiler can't know the
*format string* at compile time.

As for how you will cast, (you'll prolly have to read the format string)
but whatever you decide, you will still have decide for each of your
sprintf calls what they should be cast to, and when you actually call
the function, the decision will have been made, and it is based on
the types of the arguments passed in (be it by cast or not) that the
compiler knows how to deal with the function.


 >> 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*).


 >huh?
Suppose I write a variadic function called addem().  It takes some
number of ints adds them, and returns their sum.  No format string
here, the compiler still has to know how to setup the function, so
it looks at the types of the arguments you pass in, and sets it up
from that.


 >/fc

Hope this helps

-- 
Sam Reynolds
cloud at chool.com




More information about the openssh-unix-dev mailing list