From 62602c10a32de32cb30480a3932dcf4556f113f4 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 31 Aug 2012 16:19:58 -0700 Subject: [PATCH] Fixing potential for out of bounds read_cursor --- src/networking.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/networking.c b/src/networking.c index 25337a94..e766d6f8 100644 --- a/src/networking.c +++ b/src/networking.c @@ -925,7 +925,9 @@ int extract_to_terminator(statsite_conn_info *conn, char terminator, char **buf, *buf_len = term_addr - *buf + 1; // Difference between the terminator and location *term_addr = '\0'; // Add a null terminator *should_free = 0; // No need to free, in the buffer - conn->input.read_cursor = term_addr - conn->input.buffer + 1; // Push the read cursor forward + + // Push the read cursor forward + conn->input.read_cursor = (term_addr - conn->input.buffer + 1) % conn->input.buf_size; return 0; }