gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8166 - libmicrohttpd/src/testcurl/https


From: gnunet
Subject: [GNUnet-SVN] r8166 - libmicrohttpd/src/testcurl/https
Date: Sun, 1 Feb 2009 23:57:28 -0700 (MST)

Author: grothoff
Date: 2009-02-01 23:57:28 -0700 (Sun, 01 Feb 2009)
New Revision: 8166

Modified:
   libmicrohttpd/src/testcurl/https/mhds_get_test.c
   libmicrohttpd/src/testcurl/https/mhds_multi_daemon_test.c
   libmicrohttpd/src/testcurl/https/tls_alert_test.c
   libmicrohttpd/src/testcurl/https/tls_authentication_test.c
   libmicrohttpd/src/testcurl/https/tls_cipher_change_test.c
   libmicrohttpd/src/testcurl/https/tls_daemon_options_test.c
   libmicrohttpd/src/testcurl/https/tls_multi_thread_mode_test.c
   libmicrohttpd/src/testcurl/https/tls_session_time_out_test.c
Log:
minor bugfixes in testcases

Modified: libmicrohttpd/src/testcurl/https/mhds_get_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/mhds_get_test.c    2009-02-02 06:34:30 UTC 
(rev 8165)
+++ libmicrohttpd/src/testcurl/https/mhds_get_test.c    2009-02-02 06:57:28 UTC 
(rev 8166)
@@ -147,22 +147,19 @@
   doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
   if (NULL == (doc_path = malloc (doc_path_len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
   if (getcwd (doc_path, doc_path_len) == NULL)
     {
-      fclose (test_fd);
-      free (doc_path);
       fprintf (stderr, "Error: failed to get working directory. %s\n",
                strerror (errno));
+      free (doc_path);
       return -1;
     }
 
   if (NULL == (mem_test_file_local = malloc (len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
@@ -170,15 +167,17 @@
   fseek (test_fd, 0, SEEK_SET);
   if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
     {
-      fclose (test_fd);
+      free (mem_test_file_local);
+      free (doc_path);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
       return -1;
     }
 
-  if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
+  if (NULL == (cbc.buf = malloc (len)))
     {
-      fclose (test_fd);
+      free (mem_test_file_local);
+      free (doc_path);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
@@ -219,6 +218,9 @@
       fprintf (stderr, "curl_easy_perform failed: `%s'\n",
                curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
+      free (mem_test_file_local);
+      free (doc_path);
+      free (cbc.buf);
       return errornum;
     }
 
@@ -229,6 +231,7 @@
       fprintf (stderr, "Error: local file & received file differ.\n");
       free (cbc.buf);
       free (mem_test_file_local);
+      free (doc_path);
       return -1;
     }
 
@@ -281,12 +284,14 @@
     {
       fprintf (stderr, "Error: failed to write `%s. %s'\n",
                test_file_name, strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
   if (fflush (test_fd))
     {
       fprintf (stderr, "Error: failed to flush test file stream. %s\n",
                strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
 
@@ -341,6 +346,7 @@
   if (0 != curl_global_init (CURL_GLOBAL_ALL))
     {
       fprintf (stderr, "Error: %s\n", strerror (errno));
+      fclose (test_fd);
       return -1;
     }
 

Modified: libmicrohttpd/src/testcurl/https/mhds_multi_daemon_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/mhds_multi_daemon_test.c   2009-02-02 
06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/mhds_multi_daemon_test.c   2009-02-02 
06:57:28 UTC (rev 8166)
@@ -143,13 +143,11 @@
   doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
   if (NULL == (doc_path = malloc (doc_path_len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
   if (getcwd (doc_path, doc_path_len) == NULL)
     {
-      fclose (test_fd);
       free (doc_path);
       fprintf (stderr, "Error: failed to get working directory. %s\n",
                strerror (errno));
@@ -160,7 +158,6 @@
   fseek (test_fd, 0, SEEK_SET);
   if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
     {
-      fclose (test_fd);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
       return -1;
@@ -168,7 +165,6 @@
 
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
     {
-      fclose (test_fd);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
       return -1;
@@ -294,12 +290,14 @@
     {
       fprintf (stderr, "Error: failed to write `%s. %s'\n",
                test_file_name, strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
   if (fflush (test_fd))
     {
       fprintf (stderr, "Error: failed to flush test file stream. %s\n",
                strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
 
@@ -327,6 +325,7 @@
     {
       fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__,
                __FUNCTION__);
+      fclose (test_fd);
       return -1;
     }
 

Modified: libmicrohttpd/src/testcurl/https/tls_alert_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_alert_test.c   2009-02-02 06:34:30 UTC 
(rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_alert_test.c   2009-02-02 06:57:28 UTC 
(rev 8166)
@@ -62,7 +62,7 @@
        MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred)
 {
   int ret;
-  const char **err_pos;
+  const char *err_pos;
 
   MHD__gnutls_certificate_allocate_credentials (xcred);
 
@@ -74,7 +74,7 @@
                                             GNUTLS_X509_FMT_PEM);
 
   MHD__gnutls_init (session, GNUTLS_CLIENT);
-  ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos);
+  ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", &err_pos);
   if (ret < 0)
     {
       return -1;
@@ -112,6 +112,13 @@
   struct sockaddr_in sa;
 
   sd = socket (AF_INET, SOCK_STREAM, 0);
+  if (sd == -1)
+    {
+      fprintf(stderr,
+             "Failed to create socket: %s\n",
+             strerror(errno));
+      return -1;
+    }
   memset (&sa, '\0', sizeof (struct sockaddr_in));
   sa.sin_family = AF_INET;
   sa.sin_port = htons (42433);
@@ -161,6 +168,13 @@
   struct sockaddr_in sa;
 
   sd = socket (AF_INET, SOCK_STREAM, 0);
+  if (sd == -1)
+    {
+      fprintf(stderr,
+             "Failed to create socket: %s\n",
+             strerror(errno));
+      return -1;
+    }
   memset (&sa, '\0', sizeof (struct sockaddr_in));
   sa.sin_family = AF_INET;
   sa.sin_port = htons (42433);

Modified: libmicrohttpd/src/testcurl/https/tls_authentication_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_authentication_test.c  2009-02-02 
06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_authentication_test.c  2009-02-02 
06:57:28 UTC (rev 8166)
@@ -144,39 +144,39 @@
   doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
   if (NULL == (doc_path = malloc (doc_path_len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
   if (getcwd (doc_path, doc_path_len) == NULL)
     {
-      fclose (test_fd);
-      free (doc_path);
       fprintf (stderr, "Error: failed to get working directory. %s\n",
                strerror (errno));
+      free (doc_path);
       return -1;
     }
 
   if (NULL == (mem_test_file_local = malloc (len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
+      free (doc_path);
       return -1;
     }
 
   fseek (test_fd, 0, SEEK_SET);
   if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
     {
-      fclose (test_fd);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
+      free (doc_path);
+      free (mem_test_file_local);
       return -1;
     }
 
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
+      free (doc_path);
+      free (mem_test_file_local);
       return -1;
     }
   cbc.size = len;
@@ -218,6 +218,9 @@
       fprintf (stderr, "curl_easy_perform failed: `%s'\n",
                curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
+      free (cbc.buf);
+      free (doc_path);
+      free (mem_test_file_local);
       return errornum;
     }
 
@@ -228,6 +231,7 @@
       fprintf (stderr, "Error: local file & received file differ.\n");
       free (cbc.buf);
       free (mem_test_file_local);
+      free (doc_path);
       return -1;
     }
 
@@ -308,12 +312,14 @@
     {
       fprintf (stderr, "Error: failed to write `%s. %s'\n",
                ca_cert_file_name, strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
   if (fflush (fd))
     {
       fprintf (stderr, "Error: failed to flush ca cert file stream. %s\n",
                strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
 
@@ -342,6 +348,7 @@
   if (0 != curl_global_init (CURL_GLOBAL_ALL))
     {
       fprintf (stderr, "Error (code: %u)\n", errorCount);
+      fclose (test_fd);
       return -1;
     }
 

Modified: libmicrohttpd/src/testcurl/https/tls_cipher_change_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_cipher_change_test.c   2009-02-02 
06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_cipher_change_test.c   2009-02-02 
06:57:28 UTC (rev 8166)
@@ -64,7 +64,7 @@
        MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred)
 {
   int ret;
-  const char **err_pos;
+  const char *err_pos;
 
   MHD__gnutls_certificate_allocate_credentials (xcred);
 
@@ -76,7 +76,7 @@
                                             GNUTLS_X509_FMT_PEM);
 
   MHD__gnutls_init (session, GNUTLS_CLIENT);
-  ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos);
+  ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", &err_pos);
   if (ret < 0)
     {
       return -1;
@@ -116,6 +116,13 @@
   struct sockaddr_in sa;
 
   sd = socket (AF_INET, SOCK_STREAM, 0);
+  if (sd == -1)
+    {
+      fprintf(stderr,
+             "Failed to create socket: %s\n",
+             strerror(errno));
+      return -1;
+    }
   memset (&sa, '\0', sizeof (struct sockaddr_in));
   sa.sin_family = AF_INET;
   sa.sin_port = htons (42433);

Modified: libmicrohttpd/src/testcurl/https/tls_daemon_options_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_daemon_options_test.c  2009-02-02 
06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_daemon_options_test.c  2009-02-02 
06:57:28 UTC (rev 8166)
@@ -160,39 +160,37 @@
   doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
   if (NULL == (doc_path = malloc (doc_path_len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
       return -1;
     }
   if (getcwd (doc_path, doc_path_len) == NULL)
     {
-      fclose (test_fd);
-      free (doc_path);
       fprintf (stderr, "Error: failed to get working directory. %s\n",
                strerror (errno));
+      free (doc_path);
       return -1;
     }
 
   if (NULL == (mem_test_file_local = malloc (len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
+      free (doc_path);
       return -1;
     }
 
   fseek (test_fd, 0, SEEK_SET);
   if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
     {
-      fclose (test_fd);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
+      free (doc_path);
       return -1;
     }
 
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
     {
-      fclose (test_fd);
       fprintf (stderr, MHD_E_MEM);
+      free (doc_path);
       return -1;
     }
   cbc.size = len;
@@ -267,12 +265,14 @@
     {
       fprintf (stderr, "Error: failed to write `%s. %s'\n",
                test_file_name, strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
   if (fflush (test_fd))
     {
       fprintf (stderr, "Error: failed to flush test file stream. %s\n",
                strerror (errno));
+      fclose (test_fd);
       return NULL;
     }
 
@@ -406,6 +406,7 @@
   if (0 != curl_global_init (CURL_GLOBAL_ALL))
     {
       fprintf (stderr, "Error: %s\n", strerror (errno));
+      fclose (test_fd);
       return -1;
     }
 

Modified: libmicrohttpd/src/testcurl/https/tls_multi_thread_mode_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_multi_thread_mode_test.c       
2009-02-02 06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_multi_thread_mode_test.c       
2009-02-02 06:57:28 UTC (rev 8166)
@@ -189,6 +189,7 @@
     {
       fclose (test_fd);
       free (doc_path);
+      free (mem_test_file_local);
       fprintf (stderr, "Error: failed to read test file. %s\n",
                strerror (errno));
       return -1;

Modified: libmicrohttpd/src/testcurl/https/tls_session_time_out_test.c
===================================================================
--- libmicrohttpd/src/testcurl/https/tls_session_time_out_test.c        
2009-02-02 06:34:30 UTC (rev 8165)
+++ libmicrohttpd/src/testcurl/https/tls_session_time_out_test.c        
2009-02-02 06:57:28 UTC (rev 8166)
@@ -103,6 +103,13 @@
   struct sockaddr_in sa;
 
   sd = socket (AF_INET, SOCK_STREAM, 0);
+  if (sd == -1)
+    {
+      fprintf(stderr,
+             "Failed to create socket: %s\n",
+             strerror(errno));
+      return -1;
+    }
   memset (&sa, '\0', sizeof (struct sockaddr_in));
   sa.sin_family = AF_INET;
   sa.sin_port = htons (42433);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]