[syslinux:master] btrfs: print an error if finding compressed/encrypted data

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Jul 5 17:54:28 PDT 2010


Commit-ID:  31972117a90a7109413bb59e1f33d55fcbdf01db
Gitweb:     http://syslinux.zytor.com/commit/31972117a90a7109413bb59e1f33d55fcbdf01db
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 5 Jul 2010 17:50:13 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 5 Jul 2010 17:50:13 -0700

btrfs: print an error if finding compressed/encrypted data

If we find compressed or encrypted data, print an error message
instead of returning garbage.  This is suboptimal, but at least
handles the common subcase of an encrypted configuration file.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/fs/btrfs/btrfs.c |   11 ++++++++++-
 core/fs/getfssec.c    |    4 ++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index 55dce93..b6a14e3 100644
--- a/core/fs/btrfs/btrfs.c
+++ b/core/fs/btrfs/btrfs.c
@@ -530,10 +530,19 @@ static int btrfs_next_extent(struct inode *inode, uint32_t lstart)
 	ret = search_tree(fs, fs_tree, &search_key, &path);
 	if (ret) { /* impossible */
 		printf("btrfs: search extent data error!\n");
-		return 0;
+		return -1;
 	}
 	extent_item = *(struct btrfs_file_extent_item *)path.data;
 
+	if (extent_item.encryption) {
+	    printf("btrfs: found encrypted data, cannot continue!\n");
+	    return -1;
+	}
+	if (extent_item.compression) {
+	    printf("btrfs: found compressed data, cannot continue!\n");
+	    return -1;
+	}
+
 	if (extent_item.type == BTRFS_FILE_EXTENT_INLINE) {/* inline file */
 		/* we fake a extent here, and PVT of inode will tell us */
 		offset = path.offsets[0] + sizeof(struct btrfs_header)
diff --git a/core/fs/getfssec.c b/core/fs/getfssec.c
index 3d62d4e..e099b64 100644
--- a/core/fs/getfssec.c
+++ b/core/fs/getfssec.c
@@ -144,6 +144,10 @@ uint32_t generic_getfssec(struct file *file, char *buf,
 	    if (!inode->this_extent.len) {
 		/* Doesn't matter if it's contiguous... */
 		inode->this_extent = inode->next_extent;
+		if (!inode->next_extent.len) {
+		    sectors = 0; /* Failed to get anything... we're dead */
+		    break;
+		}
 	    } else if (inode->next_extent.len &&
 		inode->next_extent.pstart == next_pstart(&inode->this_extent)) {
 		/* Coalesce extents and loop */



More information about the Syslinux-commits mailing list