From 4ed4c0ef5ac535a4ee6e03a900bd1031070b7cb9 Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Mon, 24 Mar 2014 09:53:18 +0100 Subject: [PATCH] Move check of TLV length for management COMMAND messages Currently, it is assumed that the management TLV data of management COMMAND messages is always empty. This is not true for the INITIALIZE command and also for a custom command we'll be introducing. Move the check to msg_post_recv and let it check only the TLVs defined by the standard. Signed-off-by: Jiri Benc --- clock.c | 4 ---- tlv.c | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/clock.c b/clock.c index 3aa2407..10fa4b6 100644 --- a/clock.c +++ b/clock.c @@ -848,10 +848,6 @@ int clock_manage(struct clock *c, struct port *p, struct ptp_message *msg) return changed; break; case COMMAND: - if (mgt->length != 2) { - clock_management_send_error(p, msg, WRONG_LENGTH); - return changed; - } break; default: return changed; diff --git a/tlv.c b/tlv.c index f32514f..b8cdd39 100644 --- a/tlv.c +++ b/tlv.c @@ -242,6 +242,15 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, pdsnp->neighborPropDelayThresh = ntohl(pdsnp->neighborPropDelayThresh); pdsnp->asCapable = ntohl(pdsnp->asCapable); break; + case SAVE_IN_NON_VOLATILE_STORAGE: + case RESET_NON_VOLATILE_STORAGE: + case INITIALIZE: + case FAULT_LOG_RESET: + case ENABLE_PORT: + case DISABLE_PORT: + if (data_len != 0) + goto bad_length; + break; } if (extra_len) { if (extra_len % 2)