| .. | .. |
|---|
| 454 | 454 | /* panic? */ |
|---|
| 455 | 455 | return -EIO; |
|---|
| 456 | 456 | |
|---|
| 457 | + res = -EIO; |
|---|
| 458 | + if (HFS_I(main_inode)->cat_key.CName.len > HFS_NAMELEN) |
|---|
| 459 | + goto out; |
|---|
| 457 | 460 | fd.search_key->cat = HFS_I(main_inode)->cat_key; |
|---|
| 458 | 461 | if (hfs_brec_find(&fd)) |
|---|
| 459 | | - /* panic? */ |
|---|
| 460 | 462 | goto out; |
|---|
| 461 | 463 | |
|---|
| 462 | 464 | if (S_ISDIR(main_inode->i_mode)) { |
|---|
| 463 | 465 | if (fd.entrylength < sizeof(struct hfs_cat_dir)) |
|---|
| 464 | | - /* panic? */; |
|---|
| 466 | + goto out; |
|---|
| 465 | 467 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, |
|---|
| 466 | 468 | sizeof(struct hfs_cat_dir)); |
|---|
| 467 | 469 | if (rec.type != HFS_CDR_DIR || |
|---|
| .. | .. |
|---|
| 474 | 476 | hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, |
|---|
| 475 | 477 | sizeof(struct hfs_cat_dir)); |
|---|
| 476 | 478 | } else if (HFS_IS_RSRC(inode)) { |
|---|
| 479 | + if (fd.entrylength < sizeof(struct hfs_cat_file)) |
|---|
| 480 | + goto out; |
|---|
| 477 | 481 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, |
|---|
| 478 | 482 | sizeof(struct hfs_cat_file)); |
|---|
| 479 | 483 | hfs_inode_write_fork(inode, rec.file.RExtRec, |
|---|
| .. | .. |
|---|
| 482 | 486 | sizeof(struct hfs_cat_file)); |
|---|
| 483 | 487 | } else { |
|---|
| 484 | 488 | if (fd.entrylength < sizeof(struct hfs_cat_file)) |
|---|
| 485 | | - /* panic? */; |
|---|
| 489 | + goto out; |
|---|
| 486 | 490 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, |
|---|
| 487 | 491 | sizeof(struct hfs_cat_file)); |
|---|
| 488 | 492 | if (rec.type != HFS_CDR_FIL || |
|---|
| .. | .. |
|---|
| 499 | 503 | hfs_bnode_write(fd.bnode, &rec, fd.entryoffset, |
|---|
| 500 | 504 | sizeof(struct hfs_cat_file)); |
|---|
| 501 | 505 | } |
|---|
| 506 | + res = 0; |
|---|
| 502 | 507 | out: |
|---|
| 503 | 508 | hfs_find_exit(&fd); |
|---|
| 504 | | - return 0; |
|---|
| 509 | + return res; |
|---|
| 505 | 510 | } |
|---|
| 506 | 511 | |
|---|
| 507 | 512 | static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry, |
|---|