summaryrefslogtreecommitdiff
path: root/fs/squashfs/dir.c
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2011-04-18 13:19:07 -0700
committerJohn Stultz <john.stultz@linaro.org>2011-04-18 13:19:07 -0700
commit775d71e49c65f1f6aa57776ea1da62988fc9a30a (patch)
treece03cae544bacc8dda67422fd66a543dd1ae3c99 /fs/squashfs/dir.c
parent18e82d2b952ab57fc1c8a69d4fa14e562f2aecf6 (diff)
parentc1a952f48517b5545075d8eb1a5d543099bd2ae1 (diff)
Merge branch 'upstream/linaro.38' into linaro-android.38KNOWN_GOOD
Diffstat (limited to 'fs/squashfs/dir.c')
-rw-r--r--fs/squashfs/dir.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c
index 0dc340aa2be..3f79cd1d0c1 100644
--- a/fs/squashfs/dir.c
+++ b/fs/squashfs/dir.c
@@ -172,6 +172,11 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
length += sizeof(dirh);
dir_count = le32_to_cpu(dirh.count) + 1;
+
+ /* dir_count should never be larger than 256 */
+ if (dir_count > 256)
+ goto failed_read;
+
while (dir_count--) {
/*
* Read directory entry.
@@ -183,6 +188,10 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir)
size = le16_to_cpu(dire->size) + 1;
+ /* size should never be larger than SQUASHFS_NAME_LEN */
+ if (size > SQUASHFS_NAME_LEN)
+ goto failed_read;
+
err = squashfs_read_metadata(inode->i_sb, dire->name,
&block, &offset, size);
if (err < 0)