[PATCH 3/3] diff_grep: add assertions verifying that the buffers are NUL-terminated
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Sep 5, 2016, 15:45 UTC
- Message-ID
- <a264f55769cd6cfedb842710791d71b11d830091.1473090278.git.johannes.schindelin@gmx.de>
- In-Reply-To
- <cover.1473090278.git.johannes.schindelin@gmx.de>
Before calling regexec() on the file contents, we better be certain that the strings fulfill the contract of C strings assumed by said function.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- diffcore-pickaxe.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index 55067ca..88820b6 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -49,6 +49,8 @@ static int diff_grep(mmfile_t *one, mmfile_t *two, xpparam_t xpp; xdemitconf_t xecfg; + assert(!one || one->ptr[one->size] == '\0'); + assert(!two || two->ptr[two->size] == '\0'); if (!one) return !regexec(regexp, two->ptr, 1, ®match, 0); if (!two)
-- 2.10.0.windows.1.2.g732a511