AP_Filesystem: detect inconsistent parameter count

on incorrect param count invalidate it so a 2nd param ftp will get the
right count
This commit is contained in:
Andrew Tridgell 2023-01-04 15:24:36 +11:00 committed by Peter Barker
parent f0bc31cdc3
commit 0b7353bb89
1 changed files with 5 additions and 0 deletions

View File

@ -188,6 +188,11 @@ uint8_t AP_Filesystem_Param::pack_param(const struct rfile &r, struct cursor &c,
ap = AP_Param::next_scalar(&c.token, &ptype, &default_val);
}
if (ap == nullptr || (r.count && c.idx >= r.count)) {
if (r.count == 0 && c.idx != AP_Param::count_parameters()) {
// the parameter count is incorrect, invalidate so a
// repeated param download avoids an error
AP_Param::invalidate_count();
}
return 0;
}
ap->copy_name_token(c.token, name, AP_MAX_NAME_SIZE, true);