Wget2 fails to uncompress gzip stream and segfaults
$ ls -l
total 0
$ wget2 twitter.com
[0] Downloading 'twitter.com' ...
HTTP response 301 Moved Permanently [twitter.com]
[0] Downloading 'https://twitter.com/' ...
Saving 'index.html'
Failed to uncompress gzip stream (-3)
Segmentation fault
$ ls -l
total 0
-rw-r--r-- 1 ubuntu ubuntu 0 Aug 13 18:01 index.html
$
There are 2 fixes needed, it seems:
- Make uncompressing gzip stream successful
- There should be no SegFault even if gzip stream uncompressing fails
Here is the valgrind output:
ubuntu@rootkea-wget2-5055322:~/workspace/testing$ valgrind wget2 twitter.com
==43571== Memcheck, a memory error detector
==43571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==43571== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==43571== Command: wget2 twitter.com
==43571==
[0] Downloading 'twitter.com' ...
HTTP response 301 Moved Permanently [twitter.com]
[0] Downloading 'https://twitter.com/' ...
Saving 'index.html'
Failed to uncompress gzip stream (-3)
==43571== Thread 2:
==43571== Invalid read of size 8
==43571== at 0x4E4EC83: wget_decompress_get_context (decompressor.c:433)
==43571== by 0x4E55516: _decompress_error_handler (http.c:318)
==43571== by 0x4E4EC44: wget_decompress (decompressor.c:419)
==43571== by 0x4E55B8E: _on_data_chunk_recv_callback (http.c:495)
==43571== by 0x667DA34: nghttp2_session_mem_recv (nghttp2_session.c:6420)
==43571== by 0x667DEE1: nghttp2_session_recv (nghttp2_session.c:6572)
==43571== by 0x4E56B7B: wget_http_get_response_cb (http.c:809)
==43571== by 0x413B21: http_receive_response (wget.c:3101)
==43571== by 0x40F87D: downloader_thread (wget.c:1762)
==43571== by 0x50B3183: start_thread (pthread_create.c:312)
==43571== by 0x55C737C: clone (clone.S:111)
==43571== Address 0xb98a380 is 112 bytes inside a block of size 612 free'd
==43571== at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==43571== by 0x6686381: default_free (nghttp2_mem.c:36)
==43571== by 0x668643A: nghttp2_mem_free (nghttp2_mem.c:61)
==43571== by 0x666F685: nghttp2_nv_array_del (nghttp2_frame.c:773)
==43571== by 0x666DEC6: nghttp2_frame_headers_free (nghttp2_frame.c:80)
==43571== by 0x6672849: nghttp2_outbound_item_free (nghttp2_outbound_item.c:52)
==43571== by 0x667344E: active_outbound_item_reset (nghttp2_session.c:377)
==43571== by 0x667742A: session_after_frame_sent2 (nghttp2_session.c:2779)
==43571== by 0x6677ABF: nghttp2_session_mem_send_internal (nghttp2_session.c:3061)
==43571== by 0x6677E91: nghttp2_session_send (nghttp2_session.c:3206)
==43571== by 0x4E56B52: wget_http_get_response_cb (http.c:806)
==43571== by 0x413B21: http_receive_response (wget.c:3101)
==43571==
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
Failed to uncompress gzip stream (-3)
HTTP response 200 [https://twitter.com/]
==43571==
==43571== HEAP SUMMARY:
==43571== in use at exit: 4,409,276 bytes in 29,735 blocks
==43571== total heap usage: 51,018 allocs, 21,283 frees, 11,727,520 bytes allocated
==43571==
==43571== LEAK SUMMARY:
==43571== definitely lost: 0 bytes in 0 blocks
==43571== indirectly lost: 0 bytes in 0 blocks
==43571== possibly lost: 0 bytes in 0 blocks
==43571== still reachable: 4,409,276 bytes in 29,735 blocks
==43571== suppressed: 0 bytes in 0 blocks
==43571== Rerun with --leak-check=full to see details of leaked memory
==43571==
==43571== For counts of detected and suppressed errors, rerun with: -v
==43571== ERROR SUMMARY: 13 errors from 1 contexts (suppressed: 0 from 0)