Permalink
Browse files

NUL-terminate config cache buffer after reading

Change-Id: I61f47e05af500d6216f45d1e0c6e8f5f2f0d8105
Reviewed-on: http://review.couchbase.org/25372
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Mordechai Nunberg <mnunberg@haskalah.org>
  • Loading branch information...
invalid-email-address authored and mnunberg committed Mar 27, 2013
1 parent 79d911f commit 02c1e02800809b7d44a1e9124c548bdbddc8f626
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/config_cache.c
View
@@ -68,6 +68,13 @@ int lcb_load_config_cache(lcb_t instance)
fclose(fp);
+ /* write the terminal NUL for strstr */
+ if (ringbuffer_ensure_capacity(&buffer, 1) == -1) {
+ ringbuffer_destruct(&buffer);
+ return -1;
+ }
+ ringbuffer_write(&buffer, "", 1);
+
end = strstr((char *)ringbuffer_get_read_head(&buffer),
"{{{fb85b563d0a8f65fa8d3d58f1b3a0708}}}");
if (end == NULL) {

0 comments on commit 02c1e02

Please sign in to comment.