Validate quota scan failures and deny unauthorized quota queries

This commit is contained in:
evgeny committed 2026-10-06 00:29:28 +02:00
1 parent fb9e7c3351
commit 092e3e3cdc
3 files changed
+30 -3

No files matched your search

+9 -2
View File
@@ -365,9 +365,16 @@ static int store_command(struct mf_storage* s, uint64_t group, uint64_t peer, co
struct mf_disk_info info = {0};
int rc, fd;
if (q->command == MF_QUOTA) {
if (*q->path || *q->target || q->cursor || q->data_len) return MF_BAD_PACKET;
if (*q->path || *q->target || q->cursor || q->data_len) {
DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "member_files: invalid quota request owner=%llu path=%s target=%s cursor=%llu data=%u",
(unsigned long long)q->owner, q->path, q->target, (unsigned long long)q->cursor, q->data_len);
return MF_BAD_PACKET;
}
struct store_user* user = store_user_get(s, q->owner, 0);
if (user && !user->valid) return MF_IO_ERROR;
if (user && !user->valid) {
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "member_files: quota account invalid owner=%llu; restart scan required", (unsigned long long)q->owner);
return MF_IO_ERROR;
}
mf_put64(r->data, user ? user->used : 0); mf_put64(r->data + 8, s->quota);
mf_put64(r->data + 16, user ? user->reserved : 0); r->data_len = MF_QUOTA_BYTES;
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: quota response owner=%llu used=%llu reserved=%llu limit=%llu",