naoa/groonga-tokyocabinet-bench — pull request #2 by kou (2014-07-27 02:44:51+00:00)
Title: Fix buffer overflow

`sprintf()` writes terminate `'\0'` at the end. So `sprintf(...,
"%016d", ...)` needs 17 (16 + 1) bytes for buffer.

We can detect buffer overflow by adding `-D_FORTIFY_SOURCE=2` to
compile flag like:

diff --git a/Makefile b/Makefile
index a8ae9ba..059d1d4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -Wall -O2 -lgroonga -I/usr/include/groonga -ltokyocabinet
+CFLAGS = -Wall -O2 -lgroonga -I/usr/include/groonga -ltokyocabinet -D_FORTIFY_SOURCE=2

all: grn_hash_bench tchdb_bench