Get rid of some unnecessary casts and add a necessary one.
[oweals/openssl.git] / apps / s_client.c
index 594ee7ea16b47d6a8c1965993a891f166bbc3d7c..1fa157573a743751cf32436754652b8bc9f7f8d3 100644 (file)
@@ -79,8 +79,8 @@ typedef unsigned int u_int;
 #include <openssl/pem.h>
 #include "s_apps.h"
 
-#if (__VMS_VER < 70000000) /* FIONBIO used as a switch to enable ioctl,
-                             and that isn't in VMS < 7.0 */
+#if (defined(VMS) && __VMS_VER < 70000000)
+/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 #undef FIONBIO
 #endif
 
@@ -468,7 +468,7 @@ re_start:
 /*                     printf("mode tty(%d %d%d) ssl(%d%d)\n",
                                tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
 
-                       /* Note: under VMS with SOCKETSHR the third parameter
+                       /* Note: under VMS with SOCKETSHR the second parameter
                         * is currently of type (int *) whereas under other
                         * systems it is (void *) if you don't have a cast it
                         * will choke the compiler: if you do have a cast then
@@ -688,9 +688,13 @@ static void print_stuff(BIO *bio, SSL *s, int full)
 
        if (full)
                {
+               int got_a_chain = 0;
+
                sk=SSL_get_peer_cert_chain(s);
                if (sk != NULL)
                        {
+                       got_a_chain = 1; /* we don't have it for SSL2 (yet) */
+
                        BIO_printf(bio,"---\nCertificate chain\n");
                        for (i=0; i<sk_X509_num(sk); i++)
                                {
@@ -710,7 +714,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
                if (peer != NULL)
                        {
                        BIO_printf(bio,"Server certificate\n");
-                       if (!c_showcerts) /* Redundant if we showed the whole chain */
+                       if (!(c_showcerts && got_a_chain)) /* Redundant if we showed the whole chain */
                                PEM_write_bio_X509(bio,peer);
                        X509_NAME_oneline(X509_get_subject_name(peer),
                                buf,BUFSIZ);