* char *param
* char *end
* FTP_PARAM_FMT *param_format,
+ * const char** this_fmt_next_param,
* FTP_SESSION *session)
*
* Purpose: Validates the current parameter against the format
* specified.
*
- * Arguments: p => Pointer to the current packet
- * params_begin => Pointer to beginning of parameters
- * params_end => End of params buffer
- * param_format => Parameter format specifier for this command
- * session => Pointer to the session info
+ * Arguments: p => Pointer to the current packet
+ * params_begin => Pointer to beginning of parameters
+ * params_end => End of params buffer
+ * param_format => Parameter format specifier for this command
+ * this_fmt_next_param => Pointer to next parameter
+ * session => Pointer to the session info
*
* Returns: int => return code indicating error or success
*
const char* param,
const char* end,
FTP_PARAM_FMT* ThisFmt,
+ const char** this_fmt_next_param,
FTP_SESSION* session)
{
int iRet;
break;
}
- ThisFmt->next_param = this_param;
+ *this_fmt_next_param = this_param;
return FTPP_SUCCESS;
}
* char *params_begin,
* char *params_end,
* FTP_PARAM_FMT *param_format,
+ * const char** this_fmt_next_param,
* FTP_SESSION *session)
*
* Purpose: Recursively determines whether each of the parameters for
* an FTP command are valid.
*
- * Arguments: p => Pointer to the current packet
- * params_begin => Pointer to beginning of parameters
- * params_end => End of params buffer
- * param_format => Parameter format specifier for this command
- * session => Pointer to the session info
+ * Arguments: p => Pointer to the current packet
+ * params_begin => Pointer to beginning of parameters
+ * params_end => End of params buffer
+ * param_format => Parameter format specifier for this command
+ * this_fmt_next_param => Pointer to the next parameter
+ * To be used to backtrack for optional parameters that don't match
+ * session => Pointer to the session info
*
* Returns: int => return code indicating error or success
*
const char* params_begin,
const char* params_end,
FTP_PARAM_FMT* param_format,
+ const char** this_fmt_next_param,
FTP_SESSION* session)
{
int iRet = FTPP_ALERT;
if ((!ThisFmt->next_param_fmt) && (params_begin >= params_end))
return FTPP_SUCCESS;
- ThisFmt->next_param = params_begin;
-
+ *this_fmt_next_param = params_begin;
if (ThisFmt->optional_fmt)
{
/* Check against optional */
+ const char* opt_fmt_next_param = nullptr;
iRet = validate_param(p, this_param, params_end,
- ThisFmt->optional_fmt, session);
+ ThisFmt->optional_fmt, &opt_fmt_next_param, session);
if (iRet == FTPP_SUCCESS)
{
const char* next_param;
+ const char* next_fmt_next_param = opt_fmt_next_param;
NextFmt = ThisFmt->optional_fmt;
- next_param = NextFmt->next_param+1;
+ next_param = opt_fmt_next_param+1;
iRet = check_ftp_param_validity(p, next_param, params_end,
- NextFmt, session);
+ NextFmt, &next_fmt_next_param, session);
if (iRet == FTPP_SUCCESS)
{
- this_param = NextFmt->next_param+1;
+ this_param = next_fmt_next_param+1;
}
}
}
for (i=0; i<ThisFmt->numChoices && !valid; i++)
{
/* Try choice [i] */
+ const char* this_fmt_choice_next_param = nullptr;
iRet = validate_param(p, this_param, params_end,
- ThisFmt->choices[i], session);
+ ThisFmt->choices[i], &this_fmt_choice_next_param, session);
if (iRet == FTPP_SUCCESS)
{
const char* next_param;
+ const char* next_fmt_next_param = this_fmt_choice_next_param;
NextFmt = ThisFmt->choices[i];
- next_param = NextFmt->next_param+1;
+ next_param = this_fmt_choice_next_param+1;
iRet = check_ftp_param_validity(p, next_param, params_end,
- NextFmt, session);
+ NextFmt, &next_fmt_next_param, session);
if (iRet == FTPP_SUCCESS)
{
- this_param = NextFmt->next_param+1;
+ this_param = next_fmt_next_param+1;
break;
}
}
else if ((iRet != FTPP_SUCCESS) && (ThisFmt->next_param_fmt))
{
/* Check against next param */
+ const char* this_fmt_next_fmt_next_param = nullptr;
iRet = validate_param(p, this_param, params_end,
- ThisFmt->next_param_fmt, session);
+ ThisFmt->next_param_fmt, &this_fmt_next_fmt_next_param, session);
if (iRet == FTPP_SUCCESS)
{
const char* next_param;
+ const char* next_fmt_next_param = this_fmt_next_fmt_next_param;
NextFmt = ThisFmt->next_param_fmt;
- next_param = NextFmt->next_param+1;
+ next_param = this_fmt_next_fmt_next_param+1;
iRet = check_ftp_param_validity(p, next_param, params_end,
- NextFmt, session);
+ NextFmt, &next_fmt_next_param, session);
if (iRet == FTPP_SUCCESS)
{
- this_param = NextFmt->next_param+1;
+ this_param = next_fmt_next_param+1;
}
}
}
}
if (iRet == FTPP_SUCCESS)
{
- ThisFmt->next_param = this_param;
+ *this_fmt_next_param = this_param;
}
return iRet;
}
}
if (CmdConf->check_validity)
{
+ const char* next_param = nullptr;
iRet = check_ftp_param_validity(p, req->param_begin,
- req->param_end, CmdConf->param_format,
+ req->param_end, CmdConf->param_format, &next_param,
ftpssn);
/* If negative, haven't already alerted on violation */
if (iRet < 0)