summaryrefslogtreecommitdiffstats
path: root/src/util/util.h
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-08-02 16:53:20 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-09-08 09:36:21 -0400
commite5ba9ef0d556a6195db692f87deedbefc2fbef17 (patch)
treea7f34dfe8c4f5eebf20ad234803e07a6db9ed919 /src/util/util.h
parent3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458 (diff)
downloadsssd-e5ba9ef0d556a6195db692f87deedbefc2fbef17.tar.gz
sssd-e5ba9ef0d556a6195db692f87deedbefc2fbef17.tar.xz
sssd-e5ba9ef0d556a6195db692f87deedbefc2fbef17.zip
Add safe copy/move macros for uint16_t
Diffstat (limited to 'src/util/util.h')
-rw-r--r--src/util/util.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util/util.h b/src/util/util.h
index 6bcc9984d..2aa414797 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -193,6 +193,12 @@ safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter)
#define SAFEALIGN_SET_INT32(dest, value, pctr) \
SAFEALIGN_SET_VALUE(dest, value, int32_t, pctr)
+#define SAFEALIGN_COPY_UINT16(dest, src, pctr) \
+ safealign_memcpy(dest, src, sizeof(uint16_t), pctr)
+
+#define SAFEALIGN_SET_UINT16(dest, value, pctr) \
+ SAFEALIGN_SET_VALUE(dest, value, uint16_t, pctr)
+
#define SAFEALIGN_COPY_UINT32_CHECK(dest, src, len, pctr) do { \
if ((*(pctr) + sizeof(uint32_t)) > (len)) return EINVAL; \
safealign_memcpy(dest, src, sizeof(uint32_t), pctr); \
@@ -203,6 +209,11 @@ safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter)
safealign_memcpy(dest, src, sizeof(int32_t), pctr); \
} while(0)
+#define SAFEALIGN_COPY_UINT16_CHECK(dest, src, len, pctr) do { \
+ if ((*(pctr) + sizeof(uint16_t)) > (len)) return EINVAL; \
+ safealign_memcpy(dest, src, sizeof(uint16_t), pctr); \
+} while(0)
+
#include "util/dlinklist.h"
/* From debug.c */
@@ -332,7 +343,6 @@ int split_on_separator(TALLOC_CTX *mem_ctx, const char *str,
char **parse_args(const char *str);
-
/* Copy a NULL-terminated string list
* Returns NULL on out of memory error or invalid input
*/