Revision 6882c8fa

b/block/qcow2-refcount.c
1140 1140
                  s->refcount_table_offset,
1141 1141
                  s->refcount_table_size * sizeof(uint64_t));
1142 1142
    for(i = 0; i < s->refcount_table_size; i++) {
1143
        int64_t offset;
1143
        uint64_t offset, cluster;
1144 1144
        offset = s->refcount_table[i];
1145
        cluster = offset >> s->cluster_bits;
1145 1146

  
1146 1147
        /* Refcount blocks are cluster aligned */
1147 1148
        if (offset & (s->cluster_size - 1)) {
1148 1149
            fprintf(stderr, "ERROR refcount block %d is not "
1149 1150
                "cluster aligned; refcount table entry corrupted\n", i);
1150 1151
            errors++;
1152
            continue;
1153
        }
1154

  
1155
        if (cluster >= nb_clusters) {
1156
            fprintf(stderr, "ERROR refcount block %d is outside image\n", i);
1157
            errors++;
1158
            continue;
1151 1159
        }
1152 1160

  
1153 1161
        if (offset != 0) {
1154 1162
            errors += inc_refcounts(bs, refcount_table, nb_clusters,
1155 1163
                          offset, s->cluster_size);
1156
            if (refcount_table[offset / s->cluster_size] != 1) {
1164
            if (refcount_table[cluster] != 1) {
1157 1165
                fprintf(stderr, "ERROR refcount block %d refcount=%d\n",
1158
                    i, refcount_table[offset / s->cluster_size]);
1166
                    i, refcount_table[cluster]);
1159 1167
            }
1160 1168
        }
1161 1169
    }

Also available in: Unified diff