--- embedaddon/lighttpd/src/proc_open.c 2013/10/14 10:32:48 1.1.1.1 +++ embedaddon/lighttpd/src/proc_open.c 2016/11/02 10:35:00 1.1.1.2 @@ -1,3 +1,5 @@ +#include "first.h" + #include "proc_open.h" #include @@ -280,13 +282,12 @@ static void proc_read_fd_to_buffer(int fd, buffer *b) ssize_t s; for (;;) { - buffer_prepare_append(b, 512); - if ((s = read(fd, (void *)(b->ptr + b->used), 512 - 1)) <= 0) { + buffer_string_prepare_append(b, 1024); + if ((s = read(fd, (void *)(b->ptr + buffer_string_length(b)), buffer_string_space(b))) <= 0) { break; } - b->used += s; + buffer_commit(b, s); } - b->ptr[b->used] = '\0'; } /* }}} */ /* {{{ proc_open_buffer */ @@ -298,7 +299,7 @@ int proc_open_buffer(const char *command, buffer *in, } if (in) { - if (write(proc.in.fd, (void *)in->ptr, in->used) < 0) { + if (write(proc.in.fd, CONST_BUF_LEN(in)) < 0) { perror("error writing pipe"); return -1; } @@ -315,7 +316,7 @@ int proc_open_buffer(const char *command, buffer *in, } else { buffer *tmp = buffer_init(); proc_read_fd_to_buffer(proc.err.fd, tmp); - if (tmp->used > 0 && write(2, (void*)tmp->ptr, tmp->used) < 0) { + if (!buffer_string_is_empty(tmp) && write(2, CONST_BUF_LEN(tmp)) < 0) { perror("error writing pipe"); buffer_free(tmp); return -1;