|
|
bb7cd1 |
From 4aecf8a2d3962d962da1e2f98b0bb3b84a8ae536 Mon Sep 17 00:00:00 2001
|
|
|
bb7cd1 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
bb7cd1 |
Date: Thu, 23 Feb 2017 20:55:05 +0100
|
|
|
bb7cd1 |
Subject: [PATCH 18/36] UTIL: Add SAFEALIGN_COPY_UINT8_CHECK
|
|
|
bb7cd1 |
MIME-Version: 1.0
|
|
|
bb7cd1 |
Content-Type: text/plain; charset=UTF-8
|
|
|
bb7cd1 |
Content-Transfer-Encoding: 8bit
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
This macro will be used later in the KCM code
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
|
bb7cd1 |
Reviewed-by: Simo Sorce <simo@redhat.com>
|
|
|
bb7cd1 |
---
|
|
|
bb7cd1 |
src/util/util_safealign.h | 6 ++++++
|
|
|
bb7cd1 |
1 file changed, 6 insertions(+)
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
diff --git a/src/util/util_safealign.h b/src/util/util_safealign.h
|
|
|
bb7cd1 |
index 0d9a579cdbfafc30bf2d0a6ad2651c71428ebd93..57f04a17d4a38300b959c1593d756b351ebd89e8 100644
|
|
|
bb7cd1 |
--- a/src/util/util_safealign.h
|
|
|
bb7cd1 |
+++ b/src/util/util_safealign.h
|
|
|
bb7cd1 |
@@ -130,6 +130,12 @@ safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter)
|
|
|
bb7cd1 |
safealign_memcpy(dest, src, srclen, pctr); \
|
|
|
bb7cd1 |
} while(0)
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
+#define SAFEALIGN_COPY_UINT8_CHECK(dest, src, len, pctr) do { \
|
|
|
bb7cd1 |
+ if ((*(pctr) + sizeof(uint8_t)) > (len) || \
|
|
|
bb7cd1 |
+ SIZE_T_OVERFLOW(*(pctr), sizeof(uint8_t))) { return EINVAL; } \
|
|
|
bb7cd1 |
+ safealign_memcpy(dest, src, sizeof(uint8_t), pctr); \
|
|
|
bb7cd1 |
+} while(0)
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
/* Aliases for backward compatibility. */
|
|
|
bb7cd1 |
#define SAFEALIGN_SET_VALUE SAFEALIGN_SETMEM_VALUE
|
|
|
bb7cd1 |
#define SAFEALIGN_SET_INT64 SAFEALIGN_SETMEM_INT64
|
|
|
bb7cd1 |
--
|
|
|
bb7cd1 |
2.9.3
|
|
|
bb7cd1 |
|