From 8e3c0176bd4f3de626dfc8cd6946378b634f21d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sun, 8 Nov 2020 14:24:06 +0100 Subject: [PATCH] libblkid: udf: add support for unclosed sequential Write-Once media --- libblkid/src/superblocks/udf.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libblkid/src/superblocks/udf.c b/libblkid/src/superblocks/udf.c index 97ecdcbe4f..1d7820ff19 100644 --- a/libblkid/src/superblocks/udf.c +++ b/libblkid/src/superblocks/udf.c @@ -276,12 +276,24 @@ anchor: return errno ? -errno : 1; /* Check that we read correct sector and detected correct block size */ - if (le32_to_cpu(vd->tag.location) != s_off / pbs[i] + 256) - continue; + if (le32_to_cpu(vd->tag.location) == s_off / pbs[i] + 256) { + type = le16_to_cpu(vd->tag.id); + if (type == TAG_ID_AVDP) + goto real_blksz; + } - type = le16_to_cpu(vd->tag.id); - if (type == TAG_ID_AVDP) - goto real_blksz; + /* UDF-2.60: 2.2.3: Unclosed sequential Write-Once media may + * have a single AVDP present at either sector 256 or 512. */ + vd = (struct volume_descriptor *) + blkid_probe_get_buffer(pr, s_off + 512 * pbs[i], sizeof(*vd)); + if (!vd) + return errno ? -errno : 1; + + if (le32_to_cpu(vd->tag.location) == s_off / pbs[i] + 512) { + type = le16_to_cpu(vd->tag.id); + if (type == TAG_ID_AVDP) + goto real_blksz; + } } return 1; -- 2.47.3