summaryrefslogtreecommitdiffstats
path: root/libblkid
Commit message (Collapse)AuthorAgeFilesLines
* misc: cleanup UUID_STR_LEN definitionsKarel Zak2017-09-154-12/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: replace magic number 37 with UUID_STR_LENPhilip Prindeville2017-09-055-6/+14
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* libblkid: udf: Define magic constantsPali Rohár2017-08-201-4/+9
|
* libblkid: fix compiler warning [-Wformat-truncation=]Karel Zak2017-08-161-1/+1
| | | | | | | | | The MBR partition pseudo-UUID is generated from table ID and partition partno. The final UUID size limit is 37 bytes. The table ID has to be restricted to keep compiler happy (for MBR the table ID is 8 bytes as string). Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: mark UBI as RAIDKarel Zak2017-08-032-2/+2
| | | | | | | | | UBI is volume manager rather than filesystem. Note that libblkid has optimized RAIDs probing (don't search for another filesystems is RAID detected). We also don't search for RAIDs on very small devices, but this optimization is ignored for UBI char devices (size=1byte). Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: add support for UBI superblockRafał Miłecki2017-08-034-0/+54
| | | | | | | | | | | | | | | | | | UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI. Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume. In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0) while ubifs can be used on UBI volume (e.g. /dev/ubi0_0). This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libblkid: add HPE extended-XFS to known filesystemsMark Tinguely2017-07-204-0/+190
| | | | | | | | | | | | | | The HPE (formerly SGI) enhanced XFS has changed its magic version number to allow the use of EXFS and community XFS filesystems at the same time. This patch adds HPE EXFS support to libblkid. [kzak@redhat.com: - removed EXFS log prober, it uses the same magic string as XFS log] Signed-off-by: Mark Tinguely <mark.tinguely@hpe.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: Add dm-integrity superblock signatureMilan Broz2017-07-183-0/+40
| | | | | | | | | | Since the kernel version 4.12 there is a new dm-integrity module that provides an emulated per-sector metadata format for storing data integrity. This patch adds dm-integrity magic signature to blkid to recognize such a block device. Signed-off-by: Milan Broz <gmazyland@gmail.com>
* build-sys: don't use non-existing UUID_LIBSRuediger Meier2017-07-181-1/+1
| | | | | | | We've added UUID_LIBS in f77a4d1087 but I don't see what it was good for. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devicesKarel Zak2017-07-122-2/+6
| | | | | | | | | For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64 add extra warning when the ioctl is used for DM devices. It seems we can avoid this ioctl when the device has dm/uuid. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532 Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master' of https://github.com/pali/util-linuxKarel Zak2017-07-111-45/+90
|\ | | | | | | | | | | | | | | * 'master' of https://github.com/pali/util-linux: tests: update UDF test, add ID_FS_VERSION libblkid: udf: Add support for ID_FS_VERSION libblkid: udf: Fix types libblkid: udf: De-duplicate code for dstring decoding
| * libblkid: udf: Add support for ID_FS_VERSIONPali Rohár2017-07-051-1/+66
| | | | | | | | Set ID_FS_VERSION to Minimum UDF Read Revision.
| * libblkid: udf: Fix typesPali Rohár2017-07-051-8/+8
| |
| * libblkid: udf: De-duplicate code for dstring decodingPali Rohár2017-07-051-36/+16Star
| |
* | libblkid: don't check for size on UBI (char dev)Karel Zak2017-07-111-1/+1
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: allow to hide already detected signaturesKarel Zak2017-06-285-25/+133
| | | | | | | | | | | | | | | | | | | | The libblkid probing functions returns the first successful result of the filesystem/RAID/PT. Unfortunately, some signatures is possible to detect by more ways or device may contains more copies (e.g. GPT). This is no problem when we wipe signatures from the device. In this case we zeroize on-device signature and re-scan for the signature (by blkid_probe_step_back()). The problem is if we want to read all permutations without the device modification (for example wipefs(8) dry run). This patch add blkid_probe_hide_range(). The function remove (zeroize) specified signature from in-memory cached buffers. If the buffer is later re-used by probing functions then the signature is invisible and we can try detect another variant of the magic string. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: remove dead code and blkid_probe_new_value()Karel Zak2017-06-271-34/+2Star
| | | | | | The function blkid_probe_new_value() is unnecessary. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: udf: Fix parsing of UDF dstring structuresPali Rohár2017-06-221-21/+45
| | | | | | First byte of dstring is OSTA Compression ID and the last byte is length of recorded bytes (including first byte). Last byte is not a part of recorded characters, therefore it should not be treated as data to decode.
* libblkid: udf: Fix detection of UDF images with block size 1024 and 4096Pali Rohár2017-06-141-6/+7
| | | | | | | | | | | When detecting block size of UDF filesystem, try to use also block size 512, 1024, 2048 and 4096. This would allow blkid to detect UDF filesystem in image file created from 4K hard disk (which should have UDF block size 4096). Before this patch only UDF images with block size of 512 and 2048 were detected as only block size from blkid_probe_get_sectorsize() and 2048 were used (blkid_probe_get_sectorsize() returns for disk images 512).
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-142-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: fix gcc-7 warning -Wint-in-bool-contextRuediger Meier2017-06-141-1/+1
| | | | | | | | | | | | | | | | BLOCK_SIZE(sb) should be unsigned so that the left shift is defined. This was the warning: ../libblkid/src/superblocks/exfat.c: In function 'probe_exfat': ../libblkid/src/superblocks/exfat.c:40:42: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context] #define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ ../libblkid/src/superblocks/exfat.c:122:14: note: in expansion of macro 'CLUSTER_SIZE' if (!sb || !CLUSTER_SIZE(sb)) ^~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix gcc-7 sprintf warnings -Wformat-overflowRuediger Meier2017-06-141-1/+1
| | | | | | | | | | | | | | | | | | | ../login-utils/last.c: In function ‘main’: ../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=] sprintf(path, "/dev/%s", ut->ut_line); ^~ ~~ ../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32 sprintf(path, "/dev/%s", ut->ut_line); ../libblkid/src/devname.c: In function 'probe_one': ../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=] sprintf(path, "/sys/block/%s/slaves", de->d_name); ^~ ../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256 sprintf(path, "/sys/block/%s/slaves", de->d_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libblkid: (vfat) add more debug messagesKarel Zak2017-06-091-2/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix library order when linkingRuediger Meier2017-06-011-4/+4
| | | | | | | | | | We got some errors on Alpine Linux where $LTLIBINTL is non-empty: ./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file': lib/blkdev.c:282: undefined reference to `libintl_gettext collect2: error: ld returned 1 exit status Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libblkid: (docs) add missing 'since' tagsKarel Zak2017-05-233-1/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: udf: Change algorithm for reporting UUIDPali Rohár2017-05-171-26/+25Star
| | | | | | | | | | | | Ensure that reported UUID always contains only lowercase hexadecimal digits and is always 16 characters length, padded with zero digits. Volume Set Identifier is converted to UTF-8 before generating UUID from it. As it could potentially contain any Unicode character. So correctly handle both 8bit and 16bit OSTA Compressed Unicode encodings. Disks which have only lowercase hexadecimal digits in Volume Set Identifier would have same UUID as before this patch.
* libblkid: udf: Correctly handle UDF strings encoded in 8bit OSTA Compressed ↵Pali Rohár2017-05-161-8/+12
| | | | | | | | | | | | | | Unicode String encoded in 8bit OSTA Compressed Unicode contains one Unicode codepoint per 8bits. Maximal Unicode codepoint is U+FF. Which effectively means that it is equivalent to Latin1 encoding. Before this patch libblkid copied raw 8bit OSTA Compressed Unicode from disk and treated it as UTF-8. It worked fine just for UTF-8 invariants, other characters were incorrectly encoded. This patch fixes this problem. Note that processing UUID is not fixed in this patch.
* libblkid: Add support for Latin1 encoding in blkid_encode_to_utf8()Pali Rohár2017-05-162-3/+15
|
* Merge branch 'master' of https://github.com/pali/util-linuxKarel Zak2017-05-115-40/+3Star
|\ | | | | | | | | | | | | * 'master' of https://github.com/pali/util-linux: tests: Add UDF CD-ROM hybrid image (ISO+Joliet+UDF) created by Nero 6 tests: Fix test output for low-probe-udf to contain UDF data Revert "libblkid: Probe UDF volumes for ISO9660 info as well"
| * Revert "libblkid: Probe UDF volumes for ISO9660 info as well"Pali Rohár2017-05-055-40/+3Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 8053b51c7601c4a7e5f2eca45610b8228f53d408. Reporting meaningless ID_FS_LABEL=UDF_Volume written in that commit was caused by reading wrong value for UDF label and it was fixed in commit 2f2730bc77c972d613cfec421468c84f15749708. So after this revert blkid reports for UDF filesystems label of UDF filesystem and not label of ISO (if present) like other systems. In most cases UDF and ISO labels are same (sometimes just one is upper case). Commit 8053b51c7601c4a7e5f2eca45610b8228f53d408 just fixed result, not reason why blkid reported different UDF Label as Windows. Real reason was fixed in 2f2730bc77c972d613cfec421468c84f15749708.
* | libblkid: add blkid_partitions_get_name()Sami Kerola2017-05-034-0/+19
|/ | | | | | | | This new function can be use to enquiry what partition names libblkid is aware of. First use of this information will be in partx(8) to make bash completion to work without a magic list. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: udf: For better readibility use one snprintf call instead multiple ↵Pali Rohár2017-05-011-4/+5
| | | | in loop
* misc: fix some printf format stringsRuediger Meier2017-04-101-1/+2
| | | | | | | | | | | Fix compiler warnings seen on Linux/i586 and OSX/travis. #type #format #cast unsigned long %lu - uint64_t PRIu64 - fdisk_sector_t %ju (uintmax_t) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libblkid: fix typoKarel Zak2017-03-241-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: prevent OOB access while probing HFS+Tobias Stoeckmann2017-03-231-2/+4
| | | | | | | | | | | | | It is possible to perform out of boundary read accesses due to insufficient boundary checks in probe_hfsplus. The first issue occurs if the leaf count in a B-node is too small. The second happens while parsing a unicode description which is longer than 255 UTF-8 characters. The length is stored in a 16 bit integer, but the array in the struct is limited to 255 * 2, which is in sync with Apple's Open Source HFS+ implementation (HFSUniStr255). Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* libblkid: ensure uninitialized variable is not used [clang]Sami Kerola2017-03-131-5/+10
| | | | | | | | | | | | | | | | | Following condition can be true if minix file system is corrupt, and versio number is found to be greater than 3. It is fair to say described scenario is unlikely. libblkid/src/superblocks/minix.c:107:13: warning: variable 'zone_size' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (version == 3) { ^~~~~~~~~~~~ libblkid/src/superblocks/minix.c:121:6: note: uninitialized use occurs here if (zone_size != 0 || ninodes == 0 || ninodes == UINT32_MAX) ^~~~~~~~~ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: avoid overflow when initializing arraySami Kerola2017-03-131-1/+1
| | | | | | | libblkid/src/superblocks/drbdmanage.c:38:42: warning: too long initializer-string for array of char(no space for nul char) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: stop mixing declarations and codeSami Kerola2017-03-131-4/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: Fix blkid.conf parsingTobias Stoeckmann2017-03-131-1/+1
| | | | | | | | | The SEND_UEVENT=yes|no line is not properly parsed, because the offset jumps one byte too far behind the equal sign. Therefore, every configuration that contains the line "SEND_UEVENT=yes" still does not send an uevent. The fix is simple: adjust the offset to be "12" instead of "13".
* libblkid: remove unnecessary 'static' keywordKarel Zak2017-02-201-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: declare across file variables in blkidP.h [smatch scan]Sami Kerola2017-02-202-5/+5
| | | | | | | | | Else these variables will cause following warning: libblkid/src/superblocks/superblocks.c:165:29: warning: symbol 'superblocks_drv' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-202-2/+2
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-207-22/+22
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: (gpt) fix force flagKarel Zak2017-02-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix BLKID_PARTS_FORCE_GPT usageKarel Zak2017-02-141-2/+6
| | | | | | Now wipefs always inform about MBR as about PMBR. That's bug. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Fix out of bounds reads in BEFS handlingAlden Tondettar2017-01-251-32/+90
| | | | | | | | | | | | | The BEFS prober is quite trusting of whatever data is fed to it and performs almost no bounds checks. There don't seem to be any out-of-bounds writes as far as I can tell, but there are many ways a corrupted image could cause libblkid to read OOB and segfault, or hang in an infinite loop. This fix makes a few sanity-checks of the superblock, add bounds checks wherever they seem needed, and crudely checks for cycles in the B+ tree. Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
* libblkid: Fix out of bounds reads on bad GPT headerAlden Tondettar2017-01-251-8/+7Star
| | | | | | | | | | | If a GUID Partition Table claims to have more than 2**25 entries, or if the size of each entry is not exactly 128 bytes, libblkid can read out of bounds and segfault. Perform the appropriate checks. [kzak@redhat.com: - fix typo] Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Fix out of bounds reads on bad NTFS Master File TableAlden Tondettar2017-01-251-6/+6
| | | | | | | | | | | The NTFS prober does not validate certain fields in struct file_attribute, and could attempt to read the disk label from outside the space allocated for the Master File Table. Perform the appropriate checks. Note that one variable (attr_off) is now 64-bit, so a check for integer overflow has been removed as unneeded/confusing. Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
* libblkid: Fix out of bounds byte swaps in ZFS handlingAlden Tondettar2017-01-251-69/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A corrupted ZFS filesystem can trigger 32-bit endian-conversions of unintended memory locations in zfs_extract_guid_name(), in several ways: * The variable "left" (number of bytes remaining in the buffer) does not account for the 12 bytes of the nvlist header. * The field nvp->nvp_namelen (name length in name/value pair) is rounded up to the nearest multiple of 4, but only the unrounded size is checked. * The fields nvs->nvs_type, nvs_strlen, etc. are modified _before_ checking if they are within bounds. * A negative value of nvp->nvp_namelen will bypass the check that nvp->nvp_namelen fits into nvp->nvp_size (size of name/value pair). This allows for mangling of locations up to 12 + 3 + 8 == 23 bytes beyond the end of stack-based buff[4096], and up to 2**31 bytes before its beginning. Furthermore some debugging messages are printed from unchecked memory locations, possibly resulting in OOB reads or setuid programs leaking sensitive data when LIBBLKID_DEBUG is set. This fix attempts to correct all of these problems. It also eliminates the stack-based buffer (in case anything else was missed) and refactors things a bit to (hopefully) make it easier to spot any mistakes. Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>