From 1e799aa6e57dffcb7baeb130919180bef22ea085 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Tue, 21 Jul 2015 21:17:59 +0000 Subject: [PATCH] Better grouping. - group $sl filtering and validation. - this commit might change replies sent to clients, since the validation check is done eaerlier now, and we might return S_MISSING_PARAM before S_BAD_OTP for example. - this should really not cause any issues though, the order of which error is raised first should not matter to clients. --- ykval-verify.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ykval-verify.php b/ykval-verify.php index cfacbe6..55ce004 100644 --- a/ykval-verify.php +++ b/ykval-verify.php @@ -150,6 +150,11 @@ if (!isset($sl) || $sl == '') { $sl = $baseParams['__YKVAL_SYNC_DEFAULT_LEVEL__']; } +if ($sl && (preg_match("/^[0-9]+$/", $sl)==0 || ($sl<0 || $sl>100))) +{ + $myLog->log(LOG_NOTICE, 'SL is provided but not correct'); + sendResp(S_MISSING_PARAMETER, $myLog); +} if (!isset($timeout) || $timeout == '') { @@ -200,12 +205,6 @@ if (isset($nonce) && (strlen($nonce) < 16 || strlen($nonce) > 40)) sendResp(S_MISSING_PARAMETER, $myLog); } -if ($sl && (preg_match("/^[0-9]+$/", $sl)==0 || ($sl<0 || $sl>100))) -{ - $myLog->log(LOG_NOTICE, 'SL is provided but not correct'); - sendResp(S_MISSING_PARAMETER, $myLog); -} - /** * Timestamp parameter is not checked since current protocol * says that 1 means request timestamp and anything else is discarded.