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
This commit is contained in:
@@ -225,6 +225,14 @@ test_null (void)
|
|||||||
return snprintf (NULL, 0, "foo") != 3;
|
return snprintf (NULL, 0, "foo") != 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_length (void)
|
||||||
|
{
|
||||||
|
char ch = 'a';
|
||||||
|
snprintf (&ch, 0, "foo");
|
||||||
|
return ch != 'a';
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -236,5 +244,6 @@ main (int argc, char **argv)
|
|||||||
ret += cmp_with_sprintf_long_long ();
|
ret += cmp_with_sprintf_long_long ();
|
||||||
#endif
|
#endif
|
||||||
ret += test_null ();
|
ret += test_null ();
|
||||||
|
ret += test_length ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user