Forum

SIGSEGV during file upload

prototux
5 April 2015, 21:05
Hiawatha crashes when uploading (with a simple POST request) somewhat large files, i've tried with a 270MB, a 560MB and a 610MB file and it works, but with a 620MB, a 680MB or a 775MB file, it crashes. the current max request size is 5GB (just for testing)

Valgrind report: http://pastie.org/10075242 (with the 775MB file)

Hiawatha version: Hiawatha v9.12, cache, IPv6, reverse proxy, SSL (1.3.10), URL toolkit, XSLT
Operating System: ElementaryOS 0.3 "freya" (ubuntu 14.04 based)
Hugo Leisink
6 April 2015, 13:05
Replace the function merge_chunks() in src/http.c with this one and let me know if this solves your problem.
static long merge_chunks(char *buffer, int size, long *bytes_in_buffer) {
int chunk_size, ch_len, len;
long content_length = 0;
char *end, *source, *destination;

source = buffer;
destination = buffer;

do {
if ((end = strstr(source, "\r\n")) == NULL) {
return -1;
}
*end = '\0';
chunk_size = hex_to_int(source);
*end = '\r';

if (chunk_size == -1) {
return -1;
}

ch_len = end - source + 2;

if (chunk_size == 0) {
if ((len = *bytes_in_buffer - ((end + 4) - buffer)) > 0) {
memmove(destination, end + 4, len);
*bytes_in_buffer -= (ch_len + 2);
}
*(buffer + *bytes_in_buffer) = '\0';
} else if (ch_len + chunk_size + 2 > size) {
return -1;
} else if (chunk_size > 0) {
memmove(destination, end + 2, chunk_size);
destination += chunk_size;
size -= (ch_len + chunk_size + 2);
source += (ch_len + chunk_size + 2);
content_length += chunk_size;
*bytes_in_buffer -= (ch_len + 2);
}
} while (chunk_size > 0);

return content_length;
}
prototux
6 April 2015, 21:47
Still crashing.
Hugo Leisink
6 April 2015, 22:01
Try this version of http.c and let me know if it works.
Mustafa Ramadhan
16 April 2015, 17:37
@Hugo,

Trouble with latest http.c where:
1. Compile error related to monitor_count_exploit_attempt (need change to monitor_count_exploit)
2. SSL not work (unfinish loading page)
This topic has been closed.