libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit ed8cc07bcde1ea753f1de7beed581e55771f52f2
parent a01bd055ef3f1ccc26ff4f1cb0fee53fda96752d
Author: Heikki Lindholm <holin@iki.fi>
Date:   Sun, 23 Nov 2008 16:21:16 +0000

current_dir_name() is a GNU extension


Diffstat:
Msrc/testcurl/https/bug-test.c | 18+++++++++++++++++-
Msrc/testcurl/https/mhds_multi_daemon_test.c | 19++++++++++++++++++-
Msrc/testcurl/https/tls_authentication_test.c | 18+++++++++++++++++-
Msrc/testcurl/https/tls_daemon_options_test.c | 18+++++++++++++++++-
4 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/src/testcurl/https/bug-test.c b/src/testcurl/https/bug-test.c @@ -27,6 +27,7 @@ #include "platform.h" #include "microhttpd.h" +#include <limits.h> #include <sys/stat.h> #include "gnutls.h" @@ -131,6 +132,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) struct CBC cbc; CURLcode errornum; char *doc_path; + size_t doc_path_len; char url[255]; struct stat statb; @@ -142,7 +144,21 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) unsigned char *mem_test_file_local; /* setup test file path, url */ - doc_path = get_current_dir_name (); + 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)); + return -1; + } if (NULL == (mem_test_file_local = malloc (len))) { diff --git a/src/testcurl/https/mhds_multi_daemon_test.c b/src/testcurl/https/mhds_multi_daemon_test.c @@ -27,12 +27,14 @@ #include "platform.h" #include "microhttpd.h" #include <curl/curl.h> +#include <limits.h> #include <sys/stat.h> #define DEBUG_CURL_VERBOSE 0 #define PAGE_NOT_FOUND "<html><head><title>File not found</title></head><body>File not found</body></html>" +#define MHD_E_MEM "Error: memory error\n" #define MHD_E_SERVER_INIT "Error: failed to start server\n" #define MHD_E_TEST_FILE_CREAT "Error: failed to setup test file\n" @@ -126,6 +128,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version, struct CBC cbc; CURLcode errornum; char *doc_path; + size_t doc_path_len; char url[255]; size_t len; struct stat file_stat; @@ -137,7 +140,21 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version, unsigned char *mem_test_file_local; /* setup test file path, url */ - doc_path = get_current_dir_name (); + 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)); + return -1; + } mem_test_file_local = malloc (len); fseek (test_fd, 0, SEEK_SET); diff --git a/src/testcurl/https/tls_authentication_test.c b/src/testcurl/https/tls_authentication_test.c @@ -27,6 +27,7 @@ #include "platform.h" #include "microhttpd.h" #include <curl/curl.h> +#include <limits.h> #include <sys/stat.h> #define DEBUG_CURL_VERBOSE 0 @@ -128,6 +129,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) struct CBC cbc; CURLcode errornum; char *doc_path; + size_t doc_path_len; char url[255]; struct stat statb; @@ -139,7 +141,21 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) unsigned char *mem_test_file_local; /* setup test file path, url */ - doc_path = get_current_dir_name (); + 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)); + return -1; + } if (NULL == (mem_test_file_local = malloc (len))) { diff --git a/src/testcurl/https/tls_daemon_options_test.c b/src/testcurl/https/tls_daemon_options_test.c @@ -28,6 +28,7 @@ #include "microhttpd.h" #include <sys/stat.h> +#include <limits.h> #include "gnutls.h" #include <curl/curl.h> @@ -144,6 +145,7 @@ test_https_transfer (FILE * test_fd, char *cipher_suite, int proto_version) CURLcode errornum; struct CBC cbc; char *doc_path; + size_t doc_path_len; char url[255]; struct stat statb; @@ -155,7 +157,21 @@ test_https_transfer (FILE * test_fd, char *cipher_suite, int proto_version) unsigned char *mem_test_file_local; /* setup test file path, url */ - doc_path = get_current_dir_name (); + 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)); + return -1; + } if (NULL == (mem_test_file_local = malloc (len))) {