summaryrefslogtreecommitdiff
path: root/libblkid-tiny
Commit message (Collapse)AuthorAgeFilesLines
* libblkid-tiny: fix invalid open syscall return checkDaniel Danzberger2021-08-031-1/+1
| | | | | | open() returns -1 on error, not 0 (stdin). Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
* libblkid-tiny: fix buffer overflowDaniel Golle2021-05-161-1/+0
| | | | | | | | | | | | | | | | Copying device name into a fixed-length buffer is problematic as the name can be longer than the buffer, resulting in subsequent fields getting corrupted and potentially even worse things. Drop strcpy of device name and use of the copied value as it is known anyway. Before this fix: /dev/mapper/owrt--volumes--e093cc66-rw_test: UUID="c66-rw_test" LABEL="test" VERSION="1.14" TYPE="f2fs" After this fix: /dev/mapper/owrt--volumes--e093cc66-rw_test: UUID="5eda3e52-3427-493a-a6d6-ffdb5a5836fd" LABEL="test" VERSION="1.14" TYPE="f2fs" Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* Truncate FAT filesystem label until 1st occurance of a blank (0x20)Mirko Vogt2020-05-061-2/+4
| | | | | | | | | | | | | | According to spec the FAT filesystem label is not terminated by a \0-byte but instead has a fixed length where the name is padded by blanks. Before libblkid-tiny just passed the always 11 bytes long blank padded string through, however it makes matching for a filesystem label inconsistent with other filesystems, which use a \0-terminated string. Before: "foobar " After : "foobar" Signed-off-by: Mirko Vogt <mirko-openwrt@nanl.de>
* libblkid-tiny: fix f2fs labels by increasing label bufferPetr Štetiar2020-01-181-1/+1
| | | | | | | | | | | | | | | | f2fs max label length is 1024B (512 * uint16_t) which is way above current 256B used in `struct blkid_struct_probe` which renders labels on f2fs system unusable: $ mkfs.f2fs -l drive /dev/sda1 $ block info /dev/sda1 label buffer too small 1024 > 255 So increase the label buffer again in order to make enough space for f2fs labels. Fixes: FS#2735 Signed-off-by: Petr Štetiar <ynezz@true.cz>
* libblkid-tiny: fix symbol collision with full libblkidJo-Philipp Wich2019-12-223-6/+6
| | | | | | | | | | The recent introduction of blkid_new_probe() and blkid_free_probe() in the dynamically linked libblkid-tiny caused the dlopen'd libblkid.so to call into the wrong version of blkid_new_probe() within blkid_new_probe_from_filename(), leading to memory corruption and eventual segmentation faults. Fixes: b82c5c1 ("libblkid-tiny: add functions for allocating & freeing probe struct") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: vfat: Change parsing label in special casesPali Rohár2019-12-201-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit f0ca7e80d7a171701d0d04a3eae22d97f15d0683 upstream. * Use only label from the root directory and do not fallback to the label stored in boot sector. This is how MS-DOS 6.22, MS-DOS 7.10, Windows 98, Windows XP and also Windows 10 behave. Moreover Windows XP and Windows 10 do not touch label in boot sector anymore, so removing FAT label on those Windowses leads to having old label still stored in boot sector (which MS-DOS and Windows fully ignore). * Label entry "NO NAME" in root directory is treated as label "NO NAME" instead of empty label. In root directory it has no special meaning. String "NO NAME" has a special meaning (empty label) only for label stored in boot sector. * Label from the boot sector is now stored into LABEL_FATBOOT field. So if there are applications which depends or needs to read this label, they have ability. After this change LABEL always correspondent to the label from the root directory and LABEL_FATBOOT to the label stored in the boot sector. If some of those labels is missing or is not present (e.g. "NO LABEL" in boot sector) then particular field is not set. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> [rmilecki: drop unneeded now downstream hacks for handling spaces] Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libblkid-tiny: vfat: Fix reading labels which starts with byte 0x05Pali Rohár2019-12-201-0/+2
| | | | | | | | | | commit e526f503918cc29d8b1ccf36a5c3a34645d2be6e upstream. When FAT directory entry has leading byte 0x05 it is interpreted as byte 0xE5. This is how FAT stores file name which starts with byte 0xE5 as leading byte in 0xE5 in FAT directory entry means that file slot is empty. Fixes: #533
* libblkid-tiny: add blkid_probe_set_id_label() stubRafał Miłecki2019-12-202-1/+7
| | | | | | | This stub will allow porting more upstream code without commenting out calls and them unused variables. This will simplify maintenance. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libblkid-tiny: use separated buffer for each block device readRafał Miłecki2019-12-203-22/+39
| | | | | | | | | | | | | | | | This allows reading multiple chunks of block device data and operating on them simultaneously. Previous implementation was using a single buffer (except for reading more data than allocated size) and subsequent reads were corrupting memory of previously returned buffers. This fixes e.g. problem with reading NTFS UUID and validating VFAT signature. Implementation is based on original libblkid code which handles it similarly. Buffers are put on probe internal list and freed when releasing a probe struct. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libblkid-tiny: add functions for allocating & freeing probe structRafał Miłecki2019-12-202-0/+34
| | | | | | | | | | This adds blkid_new_probe() and blkid_free_probe() which have to be used in place of simple struct memory allocation. They will allow extending probe struct by any extra initialization code and resources release. Newly introduced probe.c file is based on original libblkid's code. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* libblkid-tiny: ntfs: fix use-after-freeYousong Zhou2019-10-271-5/+7
| | | | | | | | The memory pointed to by ns can be reallocated when checking mft records Fixes FS#2129 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* mkdev: Avoid out of bounds readHauke Mehrtens2019-09-201-2/+2
| | | | | | | | | readlink() truncates and does not null terminate the string when more bytes would be written than available. Just increase the char array by one and assume that there is a problem when all bytes are needed. Coverity: #1330087, #1329991 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* libblkid-tiny: use blkid_probe_set_utf8label for label setAnsuel Smith2019-09-033-9/+1
| | | | Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
* libblkid-tiny: adds blkid_probe_set_utf8label supportAnsuel Smith2019-09-033-0/+92
| | | | | | Currently set_utf8label support is missing. Adds a stripped down version of encode.c file from original libblkid and adds the function to libblkid-tiny.c. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
* libblkid-tiny: increment label size to 256Ansuel Smith2019-07-011-1/+1
| | | | | | Btrfs max label lenght is 255. Increment the blkid_struct_probe struct to respect this new max value. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
* libblkid-tiny: fix wrong btrfs label lengthAnsuel Smith2019-07-011-1/+1
| | | | | | Btrfs label length is 256 included the termination char ( '\0' ) as the real max length is 255 (less than 256 from the wiki). Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
* strip trailing spaces from vfat labelsJohn Crispin2018-02-111-1/+8
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* fix vfat volume labelJohn Crispin2018-02-111-1/+1
| | | | | | the libblkid copies len+1 bytes causing a buffer overrun. Signed-off-by: John Crispin <john@phrozen.org>
* libblkid-tiny: add support for NTFS superblockRafał Miłecki2017-12-292-0/+229
| | | | | | | | | Its copied from the util-linux project and its libblkid. Call to the blkid_probe_set_utf8label was commented out due to libblkid-tiny not supporting it yet. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org>
* libblkid-tiny: add support for UBI superblockRafał Miłecki2017-08-073-0/+53
| | | | | | | | | | | 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. 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>
* add missing includesFelix Fietkau2017-02-111-0/+1
| | | | | | | On glibc 2.25, sys/sysmacros.h needs to be included for makedev, major and minor. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* libblkid-tiny: remove unused name memberJo-Philipp Wich2016-10-171-1/+0
| | | | | | | The "name" member of struct blkid_struct_probe is not used anywhere anymore so remove it from the definition to save some stack and heap space. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: fix SquashFS version detection on different endian systemsJo-Philipp Wich2016-10-171-8/+8
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: avoid setting phantom UUIDsJo-Philipp Wich2016-10-171-3/+2
| | | | | | | | | | | When blkid_probe_set_uuid_as() is invoked with a non-NULL name parameter then the name parameter denotes the kind of UUID (like "EXT_JOURNAL") not the name of the file system. Only copy the UUID value to the probe uuid member if the given name is either NULL or "UUID". Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* libblkid-tiny: Add F2FS supportMartin Blumenstingl2015-10-292-0/+102
| | | | Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
* libblkid-tiny: Update the code from util-linux's libblkidMartin Blumenstingl2015-10-2914-508/+775
| | | | | | | This updates the relevant source files to util-linux changeset 4419ffb9eff5801fdbd385a4a6199b3877f802ad. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
* properly handle return codesJohn Crispin2015-03-282-3/+3
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* switch to _DEFAULT_SOURCE for modern glibc compatJohn Crispin2015-03-121-1/+1
| | | | Signed-off-by: Jeff Waugh <jdub@bethesignal.org>
* libblkid-tiny: add btrfs probe infoDaniel Golle2015-01-072-0/+93
| | | | | | | | | | | | | | | This only adds the magic for btrfs to show btrfs volumes in block detect. In order to properly support btrfs with more than one device and avoid trying to mount the same device group once for each instance we have to make sure that only one device per group will be mounted (btrfs then automatically detects all other devices of the group). For unmounting, the opposite should be applied: umount if called for any of the devices in a mounted device group, unmount the filesystem. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* support UBI blocks (volumes)Rafał Miłecki2015-01-061-1/+1
| | | | | | We already had ubifs idinfo, so only /dev/ubiN_M support was missing. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
* various updatesJohn Crispin2014-04-012-0/+322
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* initial import of fs-tools packageJohn Crispin2014-03-1216-0/+3081
Signed-off-by: John Crispin <blogic@openwrt.org>