From f651d08834fa46c90261a8c31820b72288376758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sat, 30 Apr 2005 15:03:57 +0000 Subject: [PATCH] add check that snprintf doesn't write the NUL into the last byte when its a zero length input string git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15030 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/snprintf-test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/roken/snprintf-test.c b/lib/roken/snprintf-test.c index cdd41ccb4..e29b1ea00 100644 --- a/lib/roken/snprintf-test.c +++ b/lib/roken/snprintf-test.c @@ -225,6 +225,14 @@ test_null (void) return snprintf (NULL, 0, "foo") != 3; } +static int +test_length (void) +{ + char ch = 'a'; + snprintf (&ch, 0, "foo"); + return ch != 'a'; +} + int main (int argc, char **argv) { @@ -236,5 +244,6 @@ main (int argc, char **argv) ret += cmp_with_sprintf_long_long (); #endif ret += test_null (); + ret += test_length (); return ret; }