diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-07-26 11:05:05 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-07-26 11:05:05 +0000 |
commit | 1972785e3b15c6558abc8602675867c48089eeb3 (patch) | |
tree | 17b4b809298dfb131fd6cf643edcbe548f99ab8f /src/gns | |
parent | ea920d37dbef81b9e022f3a657b90583e4499866 (diff) | |
download | gnunet-1972785e3b15c6558abc8602675867c48089eeb3.tar.gz gnunet-1972785e3b15c6558abc8602675867c48089eeb3.zip |
-fix escaping of url
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 44fef89c2..1e558e2f9 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -191,6 +191,9 @@ struct ProxyCurlTask | |||
191 | /* DLL for tasks */ | 191 | /* DLL for tasks */ |
192 | struct ProxyCurlTask *next; | 192 | struct ProxyCurlTask *next; |
193 | 193 | ||
194 | /* Already accepted */ | ||
195 | int accepted; | ||
196 | |||
194 | /* Handle to cURL */ | 197 | /* Handle to cURL */ |
195 | CURL *curl; | 198 | CURL *curl; |
196 | 199 | ||
@@ -469,7 +472,7 @@ char i_to_hexchar (char i) | |||
469 | } | 472 | } |
470 | 473 | ||
471 | /** | 474 | /** |
472 | * Escape giben 0-terminated string | 475 | * Escape given 0-terminated string |
473 | * | 476 | * |
474 | * @param to_esc string to escapse | 477 | * @param to_esc string to escapse |
475 | * @return allocated new escaped string (MUST free!) | 478 | * @return allocated new escaped string (MUST free!) |
@@ -1742,6 +1745,16 @@ process_get_authority (void *cls, | |||
1742 | ctask); | 1745 | ctask); |
1743 | } | 1746 | } |
1744 | 1747 | ||
1748 | static void* | ||
1749 | mhd_log_callback (void* cls, const char* url) | ||
1750 | { | ||
1751 | struct ProxyCurlTask *ctask; | ||
1752 | |||
1753 | ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask)); | ||
1754 | strcpy (ctask->url, url); | ||
1755 | ctask->accepted = GNUNET_NO; | ||
1756 | return ctask; | ||
1757 | } | ||
1745 | 1758 | ||
1746 | /** | 1759 | /** |
1747 | * Main MHD callback for handling requests. | 1760 | * Main MHD callback for handling requests. |
@@ -1783,7 +1796,7 @@ create_response (void *cls, | |||
1783 | char curlurl[MAX_HTTP_URI_LENGTH]; // buffer overflow! | 1796 | char curlurl[MAX_HTTP_URI_LENGTH]; // buffer overflow! |
1784 | int ret = MHD_YES; | 1797 | int ret = MHD_YES; |
1785 | 1798 | ||
1786 | struct ProxyCurlTask *ctask; | 1799 | struct ProxyCurlTask *ctask = *con_cls; |
1787 | struct ProxyPostData *fin_post; | 1800 | struct ProxyPostData *fin_post; |
1788 | 1801 | ||
1789 | //FIXME handle | 1802 | //FIXME handle |
@@ -1798,14 +1811,13 @@ create_response (void *cls, | |||
1798 | } | 1811 | } |
1799 | 1812 | ||
1800 | 1813 | ||
1801 | if (NULL == *con_cls) | 1814 | if (GNUNET_NO == ctask->accepted) |
1802 | { | 1815 | { |
1803 | 1816 | ||
1804 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1817 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1805 | "Got %s request for %s\n", meth, url); | 1818 | "Got %s request for %s\n", meth, url); |
1806 | ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask)); | 1819 | //ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask)); |
1807 | ctask->mhd = hd; | 1820 | ctask->mhd = hd; |
1808 | *con_cls = ctask; | ||
1809 | 1821 | ||
1810 | ctask->curl = curl_easy_init(); | 1822 | ctask->curl = curl_easy_init(); |
1811 | if (NULL == ctask->curl) | 1823 | if (NULL == ctask->curl) |
@@ -1820,7 +1832,8 @@ create_response (void *cls, | |||
1820 | GNUNET_free (ctask); | 1832 | GNUNET_free (ctask); |
1821 | return ret; | 1833 | return ret; |
1822 | } | 1834 | } |
1823 | 1835 | ||
1836 | ctask->accepted = GNUNET_YES; | ||
1824 | ctask->download_in_progress = GNUNET_YES; | 1837 | ctask->download_in_progress = GNUNET_YES; |
1825 | ctask->buf_status = BUF_WAIT_FOR_CURL; | 1838 | ctask->buf_status = BUF_WAIT_FOR_CURL; |
1826 | ctask->connection = con; | 1839 | ctask->connection = con; |
@@ -1889,22 +1902,22 @@ create_response (void *cls, | |||
1889 | curl_easy_setopt (ctask->curl, CURLOPT_WRITEDATA, ctask); | 1902 | curl_easy_setopt (ctask->curl, CURLOPT_WRITEDATA, ctask); |
1890 | curl_easy_setopt (ctask->curl, CURLOPT_FOLLOWLOCATION, 0); | 1903 | curl_easy_setopt (ctask->curl, CURLOPT_FOLLOWLOCATION, 0); |
1891 | curl_easy_setopt (ctask->curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); | 1904 | curl_easy_setopt (ctask->curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
1892 | 1905 | ||
1893 | if (GNUNET_NO == ctask->mhd->is_ssl) | 1906 | if (GNUNET_NO == ctask->mhd->is_ssl) |
1894 | { | 1907 | { |
1895 | sprintf (curlurl, "http://%s:%d%s", ctask->host, ctask->port, url); | 1908 | sprintf (curlurl, "http://%s:%d%s", ctask->host, ctask->port, ctask->url); |
1896 | MHD_get_connection_values (con, | 1909 | //MHD_get_connection_values (con, |
1897 | MHD_GET_ARGUMENT_KIND, | 1910 | // MHD_GET_ARGUMENT_KIND, |
1898 | &get_uri_val_iter, curlurl); | 1911 | // &get_uri_val_iter, curlurl); |
1899 | curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl); | 1912 | curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl); |
1900 | } | 1913 | } |
1901 | strcpy (ctask->url, url); | 1914 | |
1902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1915 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1903 | "MHD: Adding new curl task for %s%s\n", ctask->host, url); | 1916 | "MHD: Adding new curl task for %s\n", ctask->host); |
1904 | MHD_get_connection_values (con, | 1917 | //MHD_get_connection_values (con, |
1905 | MHD_GET_ARGUMENT_KIND, | 1918 | // MHD_GET_ARGUMENT_KIND, |
1906 | &get_uri_val_iter, ctask->url); | 1919 | // &get_uri_val_iter, ctask->url); |
1907 | 1920 | ||
1908 | curl_easy_setopt (ctask->curl, CURLOPT_FAILONERROR, 1); | 1921 | curl_easy_setopt (ctask->curl, CURLOPT_FAILONERROR, 1); |
1909 | curl_easy_setopt (ctask->curl, CURLOPT_CONNECTTIMEOUT, 600L); | 1922 | curl_easy_setopt (ctask->curl, CURLOPT_CONNECTTIMEOUT, 600L); |
1910 | curl_easy_setopt (ctask->curl, CURLOPT_TIMEOUT, 600L); | 1923 | curl_easy_setopt (ctask->curl, CURLOPT_TIMEOUT, 600L); |
@@ -2509,6 +2522,8 @@ add_handle_to_ssl_mhd (struct GNUNET_NETWORK_Handle *h, const char* domain) | |||
2509 | MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL, | 2522 | MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL, |
2510 | MHD_OPTION_HTTPS_MEM_KEY, pgc->key, | 2523 | MHD_OPTION_HTTPS_MEM_KEY, pgc->key, |
2511 | MHD_OPTION_HTTPS_MEM_CERT, pgc->cert, | 2524 | MHD_OPTION_HTTPS_MEM_CERT, pgc->cert, |
2525 | MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, | ||
2526 | NULL, | ||
2512 | MHD_OPTION_END); | 2527 | MHD_OPTION_END); |
2513 | 2528 | ||
2514 | GNUNET_assert (hd->daemon != NULL); | 2529 | GNUNET_assert (hd->daemon != NULL); |
@@ -3297,6 +3312,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3297 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16, | 3312 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16, |
3298 | MHD_OPTION_NOTIFY_COMPLETED, | 3313 | MHD_OPTION_NOTIFY_COMPLETED, |
3299 | NULL, NULL, | 3314 | NULL, NULL, |
3315 | MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, NULL, | ||
3300 | MHD_OPTION_END); | 3316 | MHD_OPTION_END); |
3301 | 3317 | ||
3302 | GNUNET_assert (httpd != NULL); | 3318 | GNUNET_assert (httpd != NULL); |