diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
index f6874ac..8a7cbcf 100644
--- a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
+++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
@@ -329,6 +329,10 @@ int hfsplus_rename_cat(u32 cnid,
 	err = hfs_brec_find(&src_fd);
 	if (err)
 		goto out;
+    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+        err = -EIO;
+        goto out;
+    }
 
 	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
 				src_fd.entrylength);
diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
index 078684f..2d57b2b 100644
--- a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
+++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
@@ -138,6 +138,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		filp->f_pos++;
 		/* fall through */
 	case 1:
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
 			printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -168,6 +173,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 			err = -EIO;
 			goto out;
 		}
+
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		type = be16_to_cpu(entry.type);
 		len = HFSPLUS_MAX_STRLEN;
diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
index f6874ac..8a7cbcf 100644
--- a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
+++ b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
@@ -329,6 +329,10 @@ int hfsplus_rename_cat(u32 cnid,
 	err = hfs_brec_find(&src_fd);
 	if (err)
 		goto out;
+    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+        err = -EIO;
+        goto out;
+    }
 
 	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
 				src_fd.entrylength);
diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
index 078684f..2d57b2b 100644
--- a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
+++ b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
@@ -138,6 +138,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		filp->f_pos++;
 		/* fall through */
 	case 1:
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
 			printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -168,6 +173,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 			err = -EIO;
 			goto out;
 		}
+
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		type = be16_to_cpu(entry.type);
 		len = HFSPLUS_MAX_STRLEN;
