sssd/0020-UTIL-Add-SAFEALIGN_COPY_UINT8_CHECK.patch
Lukas Slebodnik 387014f928 Backport upstream patches for 1.15.3 pre-release
required for building freeipa-4.5.x in rawhide
2017-04-04 16:22:51 +02:00

37 lines
1.3 KiB
Diff

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