+
+ }
+
+ return 0;
+}
+
+static int check_leaf(char *buf, struct iam_params *params)
+{
+ struct iam_leaf_head *leaf;
+ int counted_limit;
+ int leaf_count;
+
+ leaf = (struct iam_leaf_head *)buf;
+
+ params->node_info[params->current_block].node_type = LEAF_NODE;
+
+ counted_limit = node_limit(sizeof(struct iam_leaf_head),
+ params->blocksize,
+ params->keysize + params->recsize);
+ leaf_count = __le16_to_cpu(leaf->ill_count);
+
+ if (verbose)
+ printf("Leaf block, count %i, limit %i\n", leaf_count,
+ counted_limit);
+
+ if (leaf_count > counted_limit) {
+ printf("More elements (%i) then limit (%i)\n", leaf_count,
+ counted_limit);
+ return -1;
+ }
+
+ if (check_entries((unsigned char *)(buf + sizeof(struct iam_leaf_head)),
+ params->blocksize - sizeof(struct iam_leaf_head),
+ counted_limit < leaf_count ?
+ counted_limit : leaf_count, params, LEAF_NODE)) {
+ printf("Broken entries\n");
+ return -1;