summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-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 6bcc9984..2aa41479 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
*/