summaryrefslogtreecommitdiff
path: root/util-linux/volume_id/util.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-10-12 11:17:49 +0000
committerDenis Vlasenko2008-10-12 11:17:49 +0000
commitd5e305944a9db25f57b252cc9f56c18311e68481 (patch)
tree5f76ea7623209d379a9ea34bfa943ef86af2032a /util-linux/volume_id/util.c
parentcdd1f732bc5b8447dd12b59613663b7d08fce20b (diff)
downloadbusybox-d5e305944a9db25f57b252cc9f56c18311e68481.zip
busybox-d5e305944a9db25f57b252cc9f56c18311e68481.tar.gz
findfs: fix LUKS and FAT detection routines; do not exit if corrupted
FAT fs makes us try to seek past volume function old new delta volume_id_get_buffer 301 327 +26 volume_id_probe_luks 79 82 +3 get_attr_volume_id 73 65 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 29/-8) Total: 21 bytes
Diffstat (limited to 'util-linux/volume_id/util.c')
-rw-r--r--util-linux/volume_id/util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/util-linux/volume_id/util.c b/util-linux/volume_id/util.c
index 315d75c..c4d20ba 100644
--- a/util-linux/volume_id/util.c
+++ b/util-linux/volume_id/util.c
@@ -181,7 +181,7 @@ set:
buf[4], buf[5],
buf[6], buf[7],
buf[8], buf[9],
- buf[10], buf[11], buf[12], buf[13], buf[14],buf[15]);
+ buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
break;
case UUID_DCE_STRING:
memcpy(id->uuid, buf, count);
@@ -190,6 +190,9 @@ set:
}
}
+/* Do not use xlseek here. With it, single corrupted filesystem
+ * may result in attempt to seek past device -> exit.
+ * It's better to ignore such fs and continue. */
void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
{
ssize_t buf_len;
@@ -204,7 +207,10 @@ void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
/* check if we need to read */
if ((off + len) > id->sbbuf_len) {
dbg("read sbbuf len:0x%llx", (unsigned long long) (off + len));
- xlseek(id->fd, 0, SEEK_SET);
+ if (lseek(id->fd, 0, SEEK_SET) != 0) {
+ dbg("seek(0) failed");
+ return NULL;
+ }
buf_len = full_read(id->fd, id->sbbuf, off + len);
if (buf_len < 0) {
dbg("read failed (%s)", strerror(errno));
@@ -234,7 +240,10 @@ void *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
/* check if we need to read */
if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
dbg("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
- xlseek(id->fd, off, SEEK_SET);
+ if (lseek(id->fd, off, SEEK_SET) != off) {
+ dbg("seek(0x%llx) failed", (unsigned long long) off);
+ return NULL;
+ }
buf_len = full_read(id->fd, id->seekbuf, len);
if (buf_len < 0) {
dbg("read failed (%s)", strerror(errno));