From c12a0d6dcfdc55469d1bab902c72300d67f6f216 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Feb 2023 16:03:46 +0100 Subject: [PATCH] dissect-image: unknown/unsupported diskseq is indicated by 0, not by UINT64_MAX At almost all places if diskseq is not supported we encode this as diskseq zero. But in two places we got the check for that wrong, assuming it was UINT64_MAX. Fix that. --- src/shared/dissect-image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index c0d052e0ea..a71f11794c 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -435,7 +435,7 @@ static int make_partition_devname( assert(nr != 0); /* zero is not a valid partition nr */ assert(ret); - if (!FLAGS_SET(flags, DISSECT_IMAGE_DISKSEQ_DEVNODE) || diskseq == UINT64_MAX) { + if (!FLAGS_SET(flags, DISSECT_IMAGE_DISKSEQ_DEVNODE) || diskseq == 0) { /* Given a whole block device node name (e.g. /dev/sda or /dev/loop7) generate a partition * device name (e.g. /dev/sda7 or /dev/loop7p5). The rule the kernel uses is simple: if whole @@ -499,7 +499,7 @@ static int open_partition( return -ENXIO; /* Also check diskseq. */ - if (loop->diskseq > 0) { + if (loop->diskseq != 0) { uint64_t diskseq; r = fd_get_diskseq(fd, &diskseq); @@ -573,7 +573,7 @@ static int dissect_image( * Returns -ENXIO if we couldn't find any partition suitable as root or /usr partition * Returns -ENOTUNIQ if we only found multiple generic partitions and thus don't know what to do with that */ - uint64_t diskseq = m->loop ? m->loop->diskseq : UINT64_MAX; + uint64_t diskseq = m->loop ? m->loop->diskseq : 0; if (verity && verity->root_hash) { sd_id128_t fsuuid, vuuid;