From: Miroslav Lichvar Date: Tue, 19 Jan 2016 15:53:28 +0000 (+0100) Subject: cmdmon: extend initialisation tests X-Git-Tag: 2.3-pre1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cc432ff7ed7e6a5eed2faf2e74125e5824380ad;p=thirdparty%2Fchrony.git cmdmon: extend initialisation tests --- diff --git a/cmdmon.c b/cmdmon.c index e5b6cd2c..cd6e31c1 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -266,7 +266,20 @@ CAM_Initialise(int family) command_length = PKL_CommandLength(&r); padding_length = PKL_CommandPaddingLength(&r); assert(padding_length <= MAX_PADDING_LENGTH && padding_length <= command_length); - assert(command_length == 0 || command_length >= offsetof(CMD_Reply, data)); + assert((command_length >= offsetof(CMD_Request, data) && + command_length <= sizeof (CMD_Request)) || command_length == 0); + } + + for (i = 1; i < N_REPLY_TYPES; i++) { + CMD_Reply r; + int reply_length; + + r.reply = htons(i); + r.status = STT_SUCCESS; + r.data.manual_list.n_samples = htonl(MAX_MANUAL_LIST_SAMPLES); + reply_length = PKL_ReplyLength(&r); + assert((reply_length >= offsetof(CMD_Reply, data) && + reply_length <= sizeof (CMD_Reply)) || reply_length == 0); } sock_fdu = -1;