mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-11 16:15:56 -04:00
Port to platforms where printf doesn't have %zu
Reuse the existing abstraction from include/mbedtls/debug.h. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
ac8cd66bda
commit
d751406f8d
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
|
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
|
||||||
|
|
||||||
|
#include <mbedtls/debug.h>
|
||||||
#include <mbedtls/platform.h>
|
#include <mbedtls/platform.h>
|
||||||
#include <mbedtls/platform_util.h>
|
#include <mbedtls/platform_util.h>
|
||||||
#include "test/helpers.h"
|
#include "test/helpers.h"
|
||||||
@ -156,7 +157,10 @@ void memory_leak(const char *name)
|
|||||||
void test_memory_poison(const char *name)
|
void test_memory_poison(const char *name)
|
||||||
{
|
{
|
||||||
size_t start = 0, offset = 0, count = 0;
|
size_t start = 0, offset = 0, count = 0;
|
||||||
if (sscanf(name, "%*[^0-9]%zu%*[^0-9]%zu%*[^0-9]%zu",
|
if (sscanf(name,
|
||||||
|
"%*[^0-9]%" MBEDTLS_PRINTF_SIZET
|
||||||
|
"%*[^0-9]%" MBEDTLS_PRINTF_SIZET
|
||||||
|
"%*[^0-9]%" MBEDTLS_PRINTF_SIZET,
|
||||||
&start, &offset, &count) != 3) {
|
&start, &offset, &count) != 3) {
|
||||||
mbedtls_fprintf(stderr, "%s: Bad name format: %s\n", __func__, name);
|
mbedtls_fprintf(stderr, "%s: Bad name format: %s\n", __func__, name);
|
||||||
return;
|
return;
|
||||||
@ -169,18 +173,24 @@ void test_memory_poison(const char *name)
|
|||||||
memset(aligned.buf, 'a', sizeof(aligned.buf));
|
memset(aligned.buf, 'a', sizeof(aligned.buf));
|
||||||
|
|
||||||
if (start > sizeof(aligned.buf)) {
|
if (start > sizeof(aligned.buf)) {
|
||||||
mbedtls_fprintf(stderr, "%s: start=%zu > size=%zu", __func__,
|
mbedtls_fprintf(stderr,
|
||||||
start, sizeof(aligned.buf));
|
"%s: start=%" MBEDTLS_PRINTF_SIZET
|
||||||
|
" > size=%" MBEDTLS_PRINTF_SIZET,
|
||||||
|
__func__, start, sizeof(aligned.buf));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (start + count > sizeof(aligned.buf)) {
|
if (start + count > sizeof(aligned.buf)) {
|
||||||
mbedtls_fprintf(stderr, "%s: start+count=%zu > size=%zu", __func__,
|
mbedtls_fprintf(stderr,
|
||||||
start + count, sizeof(aligned.buf));
|
"%s: start+count=%" MBEDTLS_PRINTF_SIZET
|
||||||
|
" > size=%" MBEDTLS_PRINTF_SIZET,
|
||||||
|
__func__, start + count, sizeof(aligned.buf));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (offset >= count) {
|
if (offset >= count) {
|
||||||
mbedtls_fprintf(stderr, "%s: offset=%zu >= count=%zu", __func__,
|
mbedtls_fprintf(stderr,
|
||||||
offset, count);
|
"%s: offset=%" MBEDTLS_PRINTF_SIZET
|
||||||
|
" >= count=%" MBEDTLS_PRINTF_SIZET,
|
||||||
|
__func__, offset, count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user