From 9926de2cd8da73d5d949211455df6b0aea65dee5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 28 Feb 2011 21:31:46 +0100 Subject: [PATCH] quadmath-printf.c (quadmath_snprintf): Make sure that for size > 0 str is always zero terminated. * printf/quadmath-printf.c (quadmath_snprintf): Make sure that for size > 0 str is always zero terminated. From-SVN: r170572 --- libquadmath/ChangeLog | 5 +++++ libquadmath/printf/quadmath-printf.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog index 71fbc2f547b..cc4bf882d8b 100644 --- a/libquadmath/ChangeLog +++ b/libquadmath/ChangeLog @@ -1,3 +1,8 @@ +2011-02-28 Jakub Jelinek + + * printf/quadmath-printf.c (quadmath_snprintf): Make sure + that for size > 0 str is always zero terminated. + 2011-02-20 Jakub Jelinek PR bootstrap/47827 diff --git a/libquadmath/printf/quadmath-printf.c b/libquadmath/printf/quadmath-printf.c index 750dc246fcc..b70f432cce0 100644 --- a/libquadmath/printf/quadmath-printf.c +++ b/libquadmath/printf/quadmath-printf.c @@ -256,7 +256,7 @@ quadmath_snprintf (char *str, size_t size, const char *format, ...) qfp.fp = NULL; qfp.str = str; - qfp.size = size; + qfp.size = size ? size - 1 : 0; qfp.len = 0; qfp.file_p = 0; @@ -265,7 +265,7 @@ quadmath_snprintf (char *str, size_t size, const char *format, ...) else __quadmath_printf_fp (&qfp, &info, (const void *const *)&fpnum_addr2); - if (qfp.size) + if (size) *qfp.str = '\0'; return qfp.len; -- 2.30.2