summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-02-10 07:07:16 (GMT)
committerAndreas Schneider <asn@cryptomilk.org>2015-02-10 14:49:30 (GMT)
commit2c46e7dedeebac10444636356f79161a60e796e6 (patch)
treef6648d84bc2665e0b03d08bf60e7416f201528a2
parent08860c880dddc65e26efd515214b1ab1e3ad25dd (diff)
downloadcmocka-2c46e7dedeebac10444636356f79161a60e796e6.zip
cmocka-2c46e7dedeebac10444636356f79161a60e796e6.tar.gz
cmocka-2c46e7dedeebac10444636356f79161a60e796e6.tar.bz2
cmocka: Fix length calculation.
CID: #1268624 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> SQ
-rw-r--r--src/cmocka.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmocka.c b/src/cmocka.c
index 5b37688..8a7c9e1 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -1578,11 +1578,12 @@ static void vcm_print_error(const char* const format, va_list args)
cm_error_message = tmp;
}
- if (((size_t)len) <= sizeof(buffer)) {
+ if (((size_t)len) < sizeof(buffer)) {
+ /* Use len + 1 to also copy '\0' */
memcpy(cm_error_message + msg_len, buffer, len + 1);
} else {
va_copy(ap, args);
- vsnprintf(cm_error_message + msg_len, len + 1, format, ap);
+ vsnprintf(cm_error_message + msg_len, len, format, ap);
va_end(ap);
}
}