dissect-image: fix partition label version compare
The logic was borked: if we find multiple partitions of the same designator, we should first prefer the better arch, and then prefer the better version, and then the first found. Fix that. Fixes: #27897
This commit is contained in:
@@ -1217,16 +1217,19 @@ static int dissect_image(
|
||||
}
|
||||
|
||||
if (m->partitions[type.designator].found) {
|
||||
int c;
|
||||
|
||||
/* For most partition types the first one we see wins. Except for the
|
||||
* rootfs and /usr, where we do a version compare of the label, and
|
||||
* let the newest version win. This permits a simple A/B versioning
|
||||
* scheme in OS images. */
|
||||
|
||||
if (compare_arch(type.arch, m->partitions[type.designator].architecture) <= 0)
|
||||
c = compare_arch(type.arch, m->partitions[type.designator].architecture);
|
||||
if (c < 0) /* the arch we already found is better than the one we found now */
|
||||
continue;
|
||||
|
||||
if (!partition_designator_is_versioned(type.designator) ||
|
||||
strverscmp_improved(m->partitions[type.designator].label, label) >= 0)
|
||||
if (c == 0 && /* same arch? then go by version in label */
|
||||
(!partition_designator_is_versioned(type.designator) ||
|
||||
strverscmp_improved(label, m->partitions[type.designator].label) <= 0))
|
||||
continue;
|
||||
|
||||
dissected_partition_done(m->partitions + type.designator);
|
||||
|
||||
Reference in New Issue
Block a user