Noticing the few remaining uses of strncpy in dfa.c,
I thought they too should be converted to use memcpy or related.
I.e., what if the buffer data contains a NUL byte?
Then using strncpy here would copy too little, mistakenly
stopping at that NUL byte.
That would be a significant bug, definitely worth fixing...
However, so far I have been unable to exercise that code and suspect
that it is all dead code (starting with the above statements).
The test added below makes execution reach the following loop,
which no other test case did.
This code is immediately preceding the strncpy stmt listed above.
/* match with a character class? */
for (i = 0; i < work_mbc->nch_classes; i++)
if (iswctype ((wint_t) wc, work_mbc->ch_classes[i]))
If anyone can find a way to get past this loop, please
tell us so we can add a test case to do that.
From 13191ac43e8bac47c18557753675abf3a4668cb4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@...>
Date: Sat, 14 Apr 2012 11:08:23 +0200
Subject: [PATCH 4/4] tests: add a case to exercise one more block in
* tests/empty: Add add a test case for slightly improved coverage.
tests/empty | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/empty b/tests/empty
index c13b094..cdd3130 100755
@@ -75,6 +75,13 @@ for locale in C en_US.UTF-8; do
echo "Status: Wrong status code, test \#8 failed ($options $locale)"
+ # As above, but exercise a slightly different path with multi-byte input.
+ echo "İ" | LC_ALL=$locale timeout 10s grep $options -f /dev/null -e ""
+ if test $? -ne 1 ; then
+ echo "Status: Wrong status code, test \#9 failed ($options $locale)"