| .. | .. |
|---|
| 187 | 187 | mode = be16_to_cpu(perms->mode); |
|---|
| 188 | 188 | |
|---|
| 189 | 189 | i_uid_write(inode, be32_to_cpu(perms->owner)); |
|---|
| 190 | | - if (!i_uid_read(inode) && !mode) |
|---|
| 190 | + if ((test_bit(HFSPLUS_SB_UID, &sbi->flags)) || (!i_uid_read(inode) && !mode)) |
|---|
| 191 | 191 | inode->i_uid = sbi->uid; |
|---|
| 192 | 192 | |
|---|
| 193 | 193 | i_gid_write(inode, be32_to_cpu(perms->group)); |
|---|
| 194 | | - if (!i_gid_read(inode) && !mode) |
|---|
| 194 | + if ((test_bit(HFSPLUS_SB_GID, &sbi->flags)) || (!i_gid_read(inode) && !mode)) |
|---|
| 195 | 195 | inode->i_gid = sbi->gid; |
|---|
| 196 | 196 | |
|---|
| 197 | 197 | if (dir) { |
|---|
| .. | .. |
|---|
| 497 | 497 | if (type == HFSPLUS_FOLDER) { |
|---|
| 498 | 498 | struct hfsplus_cat_folder *folder = &entry.folder; |
|---|
| 499 | 499 | |
|---|
| 500 | | - if (fd->entrylength < sizeof(struct hfsplus_cat_folder)) |
|---|
| 501 | | - /* panic? */; |
|---|
| 500 | + if (fd->entrylength < sizeof(struct hfsplus_cat_folder)) { |
|---|
| 501 | + pr_err("bad catalog folder entry\n"); |
|---|
| 502 | + res = -EIO; |
|---|
| 503 | + goto out; |
|---|
| 504 | + } |
|---|
| 502 | 505 | hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, |
|---|
| 503 | 506 | sizeof(struct hfsplus_cat_folder)); |
|---|
| 504 | 507 | hfsplus_get_perms(inode, &folder->permissions, 1); |
|---|
| .. | .. |
|---|
| 518 | 521 | } else if (type == HFSPLUS_FILE) { |
|---|
| 519 | 522 | struct hfsplus_cat_file *file = &entry.file; |
|---|
| 520 | 523 | |
|---|
| 521 | | - if (fd->entrylength < sizeof(struct hfsplus_cat_file)) |
|---|
| 522 | | - /* panic? */; |
|---|
| 524 | + if (fd->entrylength < sizeof(struct hfsplus_cat_file)) { |
|---|
| 525 | + pr_err("bad catalog file entry\n"); |
|---|
| 526 | + res = -EIO; |
|---|
| 527 | + goto out; |
|---|
| 528 | + } |
|---|
| 523 | 529 | hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, |
|---|
| 524 | 530 | sizeof(struct hfsplus_cat_file)); |
|---|
| 525 | 531 | |
|---|
| .. | .. |
|---|
| 550 | 556 | pr_err("bad catalog entry used to create inode\n"); |
|---|
| 551 | 557 | res = -EIO; |
|---|
| 552 | 558 | } |
|---|
| 559 | +out: |
|---|
| 553 | 560 | return res; |
|---|
| 554 | 561 | } |
|---|
| 555 | 562 | |
|---|
| .. | .. |
|---|
| 558 | 565 | struct inode *main_inode = inode; |
|---|
| 559 | 566 | struct hfs_find_data fd; |
|---|
| 560 | 567 | hfsplus_cat_entry entry; |
|---|
| 568 | + int res = 0; |
|---|
| 561 | 569 | |
|---|
| 562 | 570 | if (HFSPLUS_IS_RSRC(inode)) |
|---|
| 563 | 571 | main_inode = HFSPLUS_I(inode)->rsrc_inode; |
|---|
| .. | .. |
|---|
| 576 | 584 | if (S_ISDIR(main_inode->i_mode)) { |
|---|
| 577 | 585 | struct hfsplus_cat_folder *folder = &entry.folder; |
|---|
| 578 | 586 | |
|---|
| 579 | | - if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) |
|---|
| 580 | | - /* panic? */; |
|---|
| 587 | + if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) { |
|---|
| 588 | + pr_err("bad catalog folder entry\n"); |
|---|
| 589 | + res = -EIO; |
|---|
| 590 | + goto out; |
|---|
| 591 | + } |
|---|
| 581 | 592 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
|---|
| 582 | 593 | sizeof(struct hfsplus_cat_folder)); |
|---|
| 583 | 594 | /* simple node checks? */ |
|---|
| .. | .. |
|---|
| 602 | 613 | } else { |
|---|
| 603 | 614 | struct hfsplus_cat_file *file = &entry.file; |
|---|
| 604 | 615 | |
|---|
| 605 | | - if (fd.entrylength < sizeof(struct hfsplus_cat_file)) |
|---|
| 606 | | - /* panic? */; |
|---|
| 616 | + if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { |
|---|
| 617 | + pr_err("bad catalog file entry\n"); |
|---|
| 618 | + res = -EIO; |
|---|
| 619 | + goto out; |
|---|
| 620 | + } |
|---|
| 607 | 621 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
|---|
| 608 | 622 | sizeof(struct hfsplus_cat_file)); |
|---|
| 609 | 623 | hfsplus_inode_write_fork(inode, &file->data_fork); |
|---|
| .. | .. |
|---|
| 624 | 638 | set_bit(HFSPLUS_I_CAT_DIRTY, &HFSPLUS_I(inode)->flags); |
|---|
| 625 | 639 | out: |
|---|
| 626 | 640 | hfs_find_exit(&fd); |
|---|
| 627 | | - return 0; |
|---|
| 641 | + return res; |
|---|
| 628 | 642 | } |
|---|