From 812da4190f8ac2f548f3bea09b85164b78d33347 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 May 2014 23:37:24 +0200 Subject: mprintf: allow %.s with data not being zero terminated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the precision is indeed shorter than the string, don't strlen() to find the end because that's not how the precision operator works. I also added a unit test for curl_msnprintf to make sure this works and that the fix doesn't a few other basic use cases. I found a POSIX compliance problem that I marked TODO in the unit test, and I figure we need to add more tests in the future. Reported-by: Török Edwin --- tests/data/test1398 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/data/test1398 (limited to 'tests/data/test1398') diff --git a/tests/data/test1398 b/tests/data/test1398 new file mode 100644 index 000000000..dd50baa62 --- /dev/null +++ b/tests/data/test1398 @@ -0,0 +1,26 @@ + + + +unittest +curl_msnprintf + + + +# +# Client-side + + +none + + +unittest + + +curl_msnprintf unit tests + + +unit1398 + + + + -- cgit v1.2.3