Temporary pragma to have GCC quiet down about deprecated functions
[openssl.git] / crypto / bio / bss_conn.c
index 49b0f69c1a1bdffc55d7f0a4d4d1d7bba73f43d8..89ab910f73b9f295f1edfeb4a8479bd97b8dea04 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/bio/bss_conn.c */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
 
 #ifndef OPENSSL_NO_SOCK
 
 
 #ifndef OPENSSL_NO_SOCK
 
+/*
+ * We are currently using deprecated functions here, and GCC warns
+ * us about them, but since we know, we don't want to hear it.
+ */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 # if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
 /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 #  undef FIONBIO
 # if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
 /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 #  undef FIONBIO
@@ -149,7 +154,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
                             break;
                         }
                     OPENSSL_free(c->param_port);
                             break;
                         }
                     OPENSSL_free(c->param_port);
-                    c->param_port = BUF_strdup(p);
+                    c->param_port = OPENSSL_strdup(p);
                 }
             }
 
                 }
             }
 
@@ -403,7 +408,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
 {
     BIO *dbio;
     int *ip;
 {
     BIO *dbio;
     int *ip;
-    const char **pptr;
+    const char **pptr = NULL;
     long ret = 1;
     BIO_CONNECT *data;
 
     long ret = 1;
     BIO_CONNECT *data;
 
@@ -426,19 +431,28 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
     case BIO_C_GET_CONNECT:
         if (ptr != NULL) {
             pptr = (const char **)ptr;
     case BIO_C_GET_CONNECT:
         if (ptr != NULL) {
             pptr = (const char **)ptr;
-            if (num == 0) {
-                *pptr = data->param_hostname;
+        }
 
 
-            } else if (num == 1) {
-                *pptr = data->param_port;
-            } else if (num == 2) {
-                *pptr = (char *)&(data->ip[0]);
-            } else if (num == 3) {
-                *((int *)ptr) = data->port;
+        if (b->init) {
+            if (pptr != NULL) {
+                ret = 1;
+                if (num == 0) {
+                    *pptr = data->param_hostname;
+                } else if (num == 1) {
+                    *pptr = data->param_port;
+                } else if (num == 2) {
+                    *pptr = (char *)&(data->ip[0]);
+                } else {
+                    ret = 0;
+                }
             }
             }
-            if ((!b->init) || (ptr == NULL))
+            if (num == 3) {
+                ret = data->port;
+            }
+        } else {
+            if (pptr != NULL)
                 *pptr = "not initialized";
                 *pptr = "not initialized";
-            ret = 1;
+            ret = 0;
         }
         break;
     case BIO_C_SET_CONNECT:
         }
         break;
     case BIO_C_SET_CONNECT:
@@ -446,10 +460,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
             b->init = 1;
             if (num == 0) {
                 OPENSSL_free(data->param_hostname);
             b->init = 1;
             if (num == 0) {
                 OPENSSL_free(data->param_hostname);
-                data->param_hostname = BUF_strdup(ptr);
+                data->param_hostname = OPENSSL_strdup(ptr);
             } else if (num == 1) {
                 OPENSSL_free(data->param_port);
             } else if (num == 1) {
                 OPENSSL_free(data->param_port);
-                data->param_port = BUF_strdup(ptr);
+                data->param_port = OPENSSL_strdup(ptr);
             } else if (num == 2) {
                 char buf[16];
                 unsigned char *p = ptr;
             } else if (num == 2) {
                 char buf[16];
                 unsigned char *p = ptr;
@@ -457,14 +471,14 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
                 BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
                              p[0], p[1], p[2], p[3]);
                 OPENSSL_free(data->param_hostname);
                 BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
                              p[0], p[1], p[2], p[3]);
                 OPENSSL_free(data->param_hostname);
-                data->param_hostname = BUF_strdup(buf);
+                data->param_hostname = OPENSSL_strdup(buf);
                 memcpy(&(data->ip[0]), ptr, 4);
             } else if (num == 3) {
                 char buf[DECIMAL_SIZE(int) + 1];
 
                 BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
                 OPENSSL_free(data->param_port);
                 memcpy(&(data->ip[0]), ptr, 4);
             } else if (num == 3) {
                 char buf[DECIMAL_SIZE(int) + 1];
 
                 BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
                 OPENSSL_free(data->param_port);
-                data->param_port = BUF_strdup(buf);
+                data->param_port = OPENSSL_strdup(buf);
                 data->port = *(int *)ptr;
             }
         }
                 data->port = *(int *)ptr;
             }
         }