diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-05 17:27:08 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-05 17:27:08 +0100 |
commit | 513c56ddcbe02e9b8469a592cae142d93d068bc8 (patch) | |
tree | 601f7eedf88685b3c1ad00e6dce3c7d373a54df0 /src/gns | |
parent | 90c803401e6dbe336c6469ff874b0005e7a2f163 (diff) | |
download | gnunet-513c56ddcbe02e9b8469a592cae142d93d068bc8.tar.gz gnunet-513c56ddcbe02e9b8469a592cae142d93d068bc8.zip |
-fix some mem corruption, fix large file download handling
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 2a6de1c30..3af571eba 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -786,6 +786,8 @@ cleanup_s5r (struct Socks5Request *s5r) | |||
786 | 786 | ||
787 | /* ************************* HTTP handling with cURL *********************** */ | 787 | /* ************************* HTTP handling with cURL *********************** */ |
788 | 788 | ||
789 | static void | ||
790 | curl_download_prepare (); | ||
789 | 791 | ||
790 | /** | 792 | /** |
791 | * Callback for MHD response generation. This function is called from | 793 | * Callback for MHD response generation. This function is called from |
@@ -824,6 +826,11 @@ mhd_content_cb (void *cls, | |||
824 | { | 826 | { |
825 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
826 | "Pausing MHD download, no data available\n"); | 828 | "Pausing MHD download, no data available\n"); |
829 | if (NULL != s5r->curl) | ||
830 | { | ||
831 | curl_easy_pause (s5r->curl, CURLPAUSE_CONT); | ||
832 | curl_download_prepare (); | ||
833 | } | ||
827 | return 0; /* more data later */ | 834 | return 0; /* more data later */ |
828 | } | 835 | } |
829 | if ( (0 == bytes_to_copy) && | 836 | if ( (0 == bytes_to_copy) && |
@@ -833,6 +840,8 @@ mhd_content_cb (void *cls, | |||
833 | "Completed MHD download\n"); | 840 | "Completed MHD download\n"); |
834 | return MHD_CONTENT_READER_END_OF_STREAM; | 841 | return MHD_CONTENT_READER_END_OF_STREAM; |
835 | } | 842 | } |
843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
844 | "Writing %lu/%lu bytes\n", bytes_to_copy, s5r->io_len); | ||
836 | GNUNET_memcpy (buf, s5r->io_buf, bytes_to_copy); | 845 | GNUNET_memcpy (buf, s5r->io_buf, bytes_to_copy); |
837 | memmove (s5r->io_buf, | 846 | memmove (s5r->io_buf, |
838 | &s5r->io_buf[bytes_to_copy], | 847 | &s5r->io_buf[bytes_to_copy], |
@@ -865,7 +874,7 @@ check_ssl_certificate (struct Socks5Request *s5r) | |||
865 | const char *name; | 874 | const char *name; |
866 | 875 | ||
867 | s5r->ssl_checked = GNUNET_YES; | 876 | s5r->ssl_checked = GNUNET_YES; |
868 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
869 | "Checking SSL certificate\n"); | 878 | "Checking SSL certificate\n"); |
870 | if (CURLE_OK != | 879 | if (CURLE_OK != |
871 | curl_easy_getinfo (s5r->curl, | 880 | curl_easy_getinfo (s5r->curl, |
@@ -1249,7 +1258,8 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx) | |||
1249 | if (sizeof (s5r->io_buf) - s5r->io_len < total) | 1258 | if (sizeof (s5r->io_buf) - s5r->io_len < total) |
1250 | { | 1259 | { |
1251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1252 | "Pausing CURL download, not enough space\n"); | 1261 | "Pausing CURL download, not enough space %lu %lu %lu\n", sizeof (s5r->io_buf), |
1262 | s5r->io_len, total); | ||
1253 | return CURL_WRITEFUNC_PAUSE; /* not enough space */ | 1263 | return CURL_WRITEFUNC_PAUSE; /* not enough space */ |
1254 | } | 1264 | } |
1255 | GNUNET_memcpy (&s5r->io_buf[s5r->io_len], | 1265 | GNUNET_memcpy (&s5r->io_buf[s5r->io_len], |
@@ -1833,7 +1843,7 @@ mhd_completed_cb (void *cls, | |||
1833 | for (header = s5r->header_head; header != NULL; header = s5r->header_head) | 1843 | for (header = s5r->header_head; header != NULL; header = s5r->header_head) |
1834 | { | 1844 | { |
1835 | GNUNET_CONTAINER_DLL_remove (s5r->header_head, | 1845 | GNUNET_CONTAINER_DLL_remove (s5r->header_head, |
1836 | s5r->header_head, | 1846 | s5r->header_tail, |
1837 | header); | 1847 | header); |
1838 | GNUNET_free (header->type); | 1848 | GNUNET_free (header->type); |
1839 | GNUNET_free (header->value); | 1849 | GNUNET_free (header->value); |
@@ -2414,6 +2424,8 @@ do_write (void *cls) | |||
2414 | if (len <= 0) | 2424 | if (len <= 0) |
2415 | { | 2425 | { |
2416 | /* write error: connection closed, shutdown, etc.; just clean up */ | 2426 | /* write error: connection closed, shutdown, etc.; just clean up */ |
2427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2428 | "Write Error\n"); | ||
2417 | cleanup_s5r (s5r); | 2429 | cleanup_s5r (s5r); |
2418 | return; | 2430 | return; |
2419 | } | 2431 | } |