hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/hfs/inode.c
....@@ -17,6 +17,7 @@
1717 #include <linux/cred.h>
1818 #include <linux/uio.h>
1919 #include <linux/xattr.h>
20
+#include <linux/blkdev.h>
2021
2122 #include "hfs_fs.h"
2223 #include "btree.h"
....@@ -351,7 +352,7 @@
351352 inode->i_mode &= ~hsb->s_file_umask;
352353 inode->i_mode |= S_IFREG;
353354 inode->i_ctime = inode->i_atime = inode->i_mtime =
354
- timespec_to_timespec64(hfs_m_to_utime(rec->file.MdDat));
355
+ hfs_m_to_utime(rec->file.MdDat);
355356 inode->i_op = &hfs_file_inode_operations;
356357 inode->i_fop = &hfs_file_operations;
357358 inode->i_mapping->a_ops = &hfs_aops;
....@@ -362,7 +363,7 @@
362363 HFS_I(inode)->fs_blocks = 0;
363364 inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
364365 inode->i_ctime = inode->i_atime = inode->i_mtime =
365
- timespec_to_timespec64(hfs_m_to_utime(rec->dir.MdDat));
366
+ hfs_m_to_utime(rec->dir.MdDat);
366367 inode->i_op = &hfs_dir_inode_operations;
367368 inode->i_fop = &hfs_dir_operations;
368369 break;
....@@ -453,14 +454,16 @@
453454 /* panic? */
454455 return -EIO;
455456
457
+ res = -EIO;
458
+ if (HFS_I(main_inode)->cat_key.CName.len > HFS_NAMELEN)
459
+ goto out;
456460 fd.search_key->cat = HFS_I(main_inode)->cat_key;
457461 if (hfs_brec_find(&fd))
458
- /* panic? */
459462 goto out;
460463
461464 if (S_ISDIR(main_inode->i_mode)) {
462465 if (fd.entrylength < sizeof(struct hfs_cat_dir))
463
- /* panic? */;
466
+ goto out;
464467 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
465468 sizeof(struct hfs_cat_dir));
466469 if (rec.type != HFS_CDR_DIR ||
....@@ -473,6 +476,8 @@
473476 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
474477 sizeof(struct hfs_cat_dir));
475478 } else if (HFS_IS_RSRC(inode)) {
479
+ if (fd.entrylength < sizeof(struct hfs_cat_file))
480
+ goto out;
476481 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
477482 sizeof(struct hfs_cat_file));
478483 hfs_inode_write_fork(inode, rec.file.RExtRec,
....@@ -481,7 +486,7 @@
481486 sizeof(struct hfs_cat_file));
482487 } else {
483488 if (fd.entrylength < sizeof(struct hfs_cat_file))
484
- /* panic? */;
489
+ goto out;
485490 hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
486491 sizeof(struct hfs_cat_file));
487492 if (rec.type != HFS_CDR_FIL ||
....@@ -498,9 +503,10 @@
498503 hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
499504 sizeof(struct hfs_cat_file));
500505 }
506
+ res = 0;
501507 out:
502508 hfs_find_exit(&fd);
503
- return 0;
509
+ return res;
504510 }
505511
506512 static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,