diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-10-31 01:23:24 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-10-31 01:23:24 +0200 |
commit | 65bbd6ca12d11c48d0333465076769abbf67476e (patch) | |
tree | 0b588d154b221c2c78970be2c4e94fd864312365 | |
parent | 38156cef9ee7dd8f704919468028202373c40e72 (diff) | |
download | connman-65bbd6ca12d11c48d0333465076769abbf67476e.tar.gz connman-65bbd6ca12d11c48d0333465076769abbf67476e.tar.bz2 connman-65bbd6ca12d11c48d0333465076769abbf67476e.zip |
Ensure that chunk buffer is '\0' terminated
-rw-r--r-- | gweb/gweb.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c index bdf90da8..02bc6591 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -323,7 +323,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, } status = g_io_channel_read_chars(channel, session->line_offset, - session->line_space, &bytes_read, NULL); + session->line_space - 1, &bytes_read, NULL); debug(session->web, "status %u bytes read %zu", status, bytes_read); @@ -336,6 +336,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, } if (session->header_done == TRUE) { + session->line_buffer[bytes_read] = '\0'; session->result.length = bytes_read; call_result_func(session, 100); return TRUE; @@ -359,6 +360,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (count == 0) { const void *ptr = session->current_line; + session->current_line[bytes_read - consumed] = '\0'; session->header_done = TRUE; session->result.buffer = ptr; session->result.length = bytes_read - consumed; |