genadb: fix maximum inner adb limit checking

cute-signatures
Timo Teräs 2021-06-07 11:00:18 +03:00
parent 429e5984c5
commit cd9aef8f7c
2 changed files with 3 additions and 1 deletions

View File

@ -272,13 +272,14 @@ struct adb_walk_gentext {
int key_printed : 1; int key_printed : 1;
}; };
#define ADB_WALK_GENADB_MAX_IDB 2
#define ADB_WALK_GENADB_MAX_NESTING 32 #define ADB_WALK_GENADB_MAX_NESTING 32
#define ADB_WALK_GENADB_MAX_VALUES 100000 #define ADB_WALK_GENADB_MAX_VALUES 100000
struct adb_walk_genadb { struct adb_walk_genadb {
struct adb_walk d; struct adb_walk d;
struct adb db; struct adb db;
struct adb idb[2]; struct adb idb[ADB_WALK_GENADB_MAX_IDB];
int nest, nestdb, num_vals; int nest, nestdb, num_vals;
struct adb_obj objs[ADB_WALK_GENADB_MAX_NESTING]; struct adb_obj objs[ADB_WALK_GENADB_MAX_NESTING];
unsigned int curkey[ADB_WALK_GENADB_MAX_NESTING]; unsigned int curkey[ADB_WALK_GENADB_MAX_NESTING];

View File

@ -43,6 +43,7 @@ static int adb_walk_genadb_start_object(struct adb_walk *d)
if (*adb_ro_kind(&dt->objs[dt->nest-1], dt->curkey[dt->nest-1]) == ADB_KIND_ADB) { if (*adb_ro_kind(&dt->objs[dt->nest-1], dt->curkey[dt->nest-1]) == ADB_KIND_ADB) {
struct adb_adb_schema *schema = container_of(&dt->objs[dt->nest-1].schema->kind, struct adb_adb_schema, kind); struct adb_adb_schema *schema = container_of(&dt->objs[dt->nest-1].schema->kind, struct adb_adb_schema, kind);
if (dt->nestdb >= ARRAY_SIZE(dt->idb)) return -E2BIG;
adb_reset(&dt->idb[dt->nestdb]); adb_reset(&dt->idb[dt->nestdb]);
dt->idb[dt->nestdb].hdr.schema = htole32(schema->schema_id); dt->idb[dt->nestdb].hdr.schema = htole32(schema->schema_id);
dt->objs[dt->nest].db = &dt->idb[dt->nestdb]; dt->objs[dt->nest].db = &dt->idb[dt->nestdb];