aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_mq_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_mq_lib.h')
-rw-r--r--src/include/gnunet_mq_lib.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 3d3a74e3b..f5f0fd701 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -501,6 +501,31 @@ struct GNUNET_MQ_MessageHandler
501 501
502 502
503/** 503/**
504 * Insert code for a "check_" function that verifies that
505 * a given variable-length message received over the network
506 * is followed by a 0-terminated string. If the message @a m
507 * is not followed by a 0-terminated string, an error is logged
508 * and the function is returned with #GNUNET_NO.
509 *
510 * @param an IPC message with proper type to determine
511 * the size, starting with a `struct GNUNET_MessageHeader`
512 */
513#define GNUNET_MQ_check_zero_termination(m) \
514 { \
515 const char *str = (const char *) &m[1]; \
516 const struct GNUNET_MessageHeader *hdr = \
517 (const struct GNUNET_MessageHeader *) m; \
518 uint16_t slen = ntohs (hdr->size) - sizeof (*m); \
519 if ( (0 == slen) || \
520 (memchr (str, 0, slen) == &str[slen - 1]) ) \
521 { \
522 GNUNET_break (0); \
523 return GNUNET_NO; \
524 } \
525 }
526
527
528/**
504 * Create a new envelope. 529 * Create a new envelope.
505 * 530 *
506 * @param mhp message header to store the allocated message header in, can be NULL 531 * @param mhp message header to store the allocated message header in, can be NULL