From 24d9eb49f1ddbef7e39cde999dae5b795acb99cb Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 3 Feb 2020 11:33:55 -0800 Subject: [PATCH] fit Put reply argument validation --- src/serverget.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/serverget.cpp b/src/serverget.cpp index 994464a..a0558fe 100644 --- a/src/serverget.cpp +++ b/src/serverget.cpp @@ -40,10 +40,21 @@ struct ServerGPR : public ServerOp return; } else if(state==Executing) { - if(cmd==CMD_PUT && !value) - throw std::logic_error("PUT reply can't include Value"); - else if(cmd==CMD_GET && this->type && (!value || Value::Helper::desc(value)!=this->type.get())) - throw std::logic_error("GET must reply with exact type previously passed to connect()"); + /* valid combinations + * GET and !!value + * RPC + * PUT w/ subcmd&0x40 and !!value + * PUT w/o subcmd&0x40 and !value + */ + + if(cmd==CMD_GET || (cmd==CMD_PUT && (subcmd&0x40))) { + if(!value || Value::Helper::desc(value)!=this->type.get()) + throw std::logic_error("GET must reply with exact type previously passed to connect()"); + + } else if(cmd==CMD_PUT) { + if(value) + throw std::logic_error("PUT reply can't include Value"); + } } Status sts{};