summaryrefslogtreecommitdiffstats
path: root/libblkid
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* libblkid: add blkid_probe_set_sectorsize()Karel Zak2017-01-134-0/+23
| | | | | | | | | The usual way is to use ioctl to ask block device for sector size, but this is useless for disk images (regular files). And the default (512-bytes) may be pretty wrong for disk images from 4K disks. Let's support a way how to specify proper sector size. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid/minix: Sanity check superblock s_state for v 1 and 2Nate Clark2017-01-041-0/+4
| | | | | | | | | | | | | | | | | Swap devices with specific values in the uuid can look like minix devices to blkid. Add an extra check to make sure the state of the filesystem has valid state flags. A couple of offending swap uuids include: 35f1f264-137f-471a-bc85-acc9f4bc04a3 35f1f264-7f13-471a-bc85-acc9f4bc04a3 35f1f264-138f-471a-bc85-acc9f4bc04a3 35f1f264-8f13-471a-bc85-acc9f4bc04a3 Without this change a swap device with any of those uuids would be detected as minix and swap by blkid. Signed-off-by: Nate Clark <nate@neworld.us>
* libblkid/minix: Use same checks for version 3Nate Clark2017-01-041-14/+23
| | | | | | | | fsck.minix performs the same sanity checks on all versions of the superblock. Update the probe to perform the same sanity checks so it is less likely a different type of filesystem will be identified as minix. Signed-off-by: Nate Clark <nate@neworld.us>
* libblkid/minix: Match minix superblock typesNate Clark2017-01-041-1/+2
| | | | | | | | | | | | | | | | | | | All of the types in the minix super block are unsigned but in probe_minix they were being treated as signed. This would cause some of the extra sanity checks to pass on a non minix device. The types were updated to match the return types of the helper functions in disk-utils/minix_programs.h This can be checked by creating a swap partition with one of these UUIDs 35f1f264-2468-471a-bc85-acc9f4bc04a3 35f1f264-6824-471a-bc85-acc9f4bc04a3 35f1f264-2478-471a-bc85-acc9f4bc04a3 35f1f264-7824-471a-bc85-acc9f4bc04a3 Prior to this change they would all be considered minix and swap by blkid. Signed-off-by: Nate Clark <nate@neworld.us>
* docs: replace FTP by HTTPS in kernel.org URLsSébastien Helleu2016-12-192-2/+2
| | | | | | | The links to ftp://ftp.kernel.org/ are replaced by https://www.kernel.org/. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: spelling, always use "cannot" instead of "can not"Ruediger Meier2016-11-301-1/+1
| | | | | | Just to be consistent ... Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: once again some printf format stringsRuediger Meier2016-10-272-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix some compiler warningsRuediger Meier2016-10-272-32/+4Star
| | | | | | | | | | libsmartcols/samples/fromfile.c:59:2: warning: passing argument 3 of 'string_to_bitmask' from incompatible pointer type text-utils/pg.c:79:0: warning: "TABSIZE" redefined libblkid/src/read.c:455:13: warning: 'debug_dump_dev' defined but not used [-Wunused-function] libblkid/src/probe.c:769:13: warning: unused function 'cdrom_size_correction' [-Wunused-function] /usr/include/sys/termios.h:3:2: warning: "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead" [-W#warnings] Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib/crc32: prefix public functionsGustavo Zacarias2016-10-192-4/+4
| | | | | | | | | | | Make the publicly-visible crc32 library functions prefixed by ul_, such as crc32() -> ul_crc32(). This is because it clashes with the crc32() function from zlib. For newer versions of glib (2.50+) zlib and libblkid are required dependencies and otherwise results in build failure when building statically. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>