diff -urN mc-4.7.1-old/lib/vfs/mc-vfs/fish.c mc-4.7.1-new/lib/vfs/mc-vfs/fish.c
old
|
new
|
|
128 | 128 | |
129 | 129 | if (strncmp(answer, "### ", 4)) { |
130 | 130 | was_garbage = 1; |
131 | | if (string_buf) |
| 131 | if (string_buf != NULL) { |
132 | 132 | g_strlcpy(string_buf, answer, string_len); |
133 | | } else return fish_decode_reply(answer+4, was_garbage); |
| 133 | } |
| 134 | } else { |
| 135 | return fish_decode_reply (answer + 4, was_garbage); |
| 136 | } |
134 | 137 | } |
135 | 138 | } |
136 | 139 | |
diff -urN mc-4.7.1-old/lib/vfs/mc-vfs/vfs.c mc-4.7.1-new/lib/vfs/mc-vfs/vfs.c
old
|
new
|
|
537 | 537 | { |
538 | 538 | int mode; |
539 | 539 | void *info; |
540 | | va_list ap; |
| 540 | struct vfs_class *vfs; |
| 541 | |
| 542 | file = vfs_canon_and_translate (filename); |
| 543 | if (file == NULL) |
| 544 | return -1; |
541 | 545 | |
542 | | char *file = vfs_canon_and_translate (filename); |
543 | | if (file != NULL) { |
544 | | struct vfs_class *vfs = vfs_get_class (file); |
| 546 | vfs = vfs_get_class (file); |
545 | 547 | |
546 | 548 | /* Get the mode flag */ |
547 | 549 | if (flags & O_CREAT) { |
548 | | va_start (ap, flags); |
| 550 | va_list ap; |
| 551 | va_start (ap, flags); |
549 | 552 | mode = va_arg (ap, int); |
550 | 553 | va_end (ap); |
551 | | } else |
| 554 | } else { |
552 | 555 | mode = 0; |
553 | | |
554 | | if (!vfs->open) { |
| 556 | } |
| 557 | if (vfs->open == NULL) { |
555 | 558 | g_free (file); |
556 | 559 | errno = -EOPNOTSUPP; |
557 | 560 | return -1; |
558 | 561 | } |
559 | | |
560 | 562 | info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ |
561 | 563 | g_free (file); |
562 | | if (!info){ |
| 564 | if (info == NULL) { |
563 | 565 | errno = ferrno (vfs); |
564 | 566 | return -1; |
565 | 567 | } |
566 | | |
567 | 568 | return vfs_new_handle (vfs, info); |
568 | | } else return -1; |
569 | 569 | } |
570 | 570 | |
571 | 571 | |
… |
… |
|
575 | 575 | struct vfs_class *vfs; \ |
576 | 576 | int result; \ |
577 | 577 | char *mpath = vfs_canon_and_translate (path); \ |
578 | | if (mpath != NULL) { \ |
| 578 | if (mpath == NULL) \ |
| 579 | return -1; \ |
579 | 580 | vfs = vfs_get_class (mpath); \ |
580 | 581 | if (vfs == NULL){ \ |
581 | 582 | g_free (mpath); \ |
… |
… |
|
586 | 587 | if (result == -1) \ |
587 | 588 | errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ |
588 | 589 | return result; \ |
589 | | } else return -1; \ |
590 | 590 | } |
591 | 591 | |
592 | 592 | MC_NAMEOP (chmod, (const char *path, mode_t mode), (vfs, mpath, mode)) |
… |
… |
|
608 | 608 | char *tmp; |
609 | 609 | |
610 | 610 | mpath = vfs_canon_and_translate (path); |
611 | | if (mpath != NULL) { |
612 | | tmp = g_strdup (name1); |
613 | | lpath = vfs_translate_path_n (tmp); |
614 | | g_free (tmp); |
615 | | |
616 | | if (lpath != NULL) { |
617 | | vfs = vfs_get_class (mpath); |
618 | | result = vfs->symlink ? (*vfs->symlink) (vfs, lpath, mpath) : -1; |
619 | | g_free (lpath); |
620 | | g_free (mpath); |
621 | | |
622 | | if (result == -1) |
623 | | errno = vfs->symlink ? ferrno (vfs) : E_NOTSUPP; |
624 | | return result; |
625 | | } |
626 | | g_free (mpath); |
| 611 | if (mpath == NULL) |
| 612 | return -1; |
| 613 | |
| 614 | tmp = g_strdup (name1); |
| 615 | lpath = vfs_translate_path_n (tmp); |
| 616 | g_free (tmp); |
| 617 | |
| 618 | if (lpath == NULL) { |
| 619 | g_free (mpath); |
| 620 | return -1; |
627 | 621 | } |
628 | | return -1; |
| 622 | vfs = vfs_get_class (mpath); |
| 623 | result = vfs->symlink ? (*vfs->symlink) (vfs, lpath, mpath) : -1; |
| 624 | g_free (mpath); |
| 625 | g_free (lpath); |
| 626 | |
| 627 | if (result == -1) |
| 628 | errno = vfs->symlink ? ferrno (vfs) : E_NOTSUPP; |
| 629 | |
| 630 | return result; |
629 | 631 | } |
630 | 632 | |
631 | 633 | #define MC_HANDLEOP(name, inarg, callarg) \ |
… |
… |
|
655 | 657 | int result; \ |
656 | 658 | char *name2, *name1; \ |
657 | 659 | name1 = vfs_canon_and_translate (fname1); \ |
658 | | if (name1 != NULL) { \ |
659 | | name2 = vfs_canon_and_translate (fname2); \ |
660 | | if (name2 != NULL) { \ |
| 660 | if (name1 == NULL) \ |
| 661 | return -1; \ |
| 662 | name2 = vfs_canon_and_translate (fname2); \ |
| 663 | if (name2 == NULL) { \ |
| 664 | g_free (name1); \ |
| 665 | return -1; \ |
| 666 | } \ |
661 | 667 | vfs = vfs_get_class (name1); \ |
662 | 668 | if (vfs != vfs_get_class (name2)){ \ |
663 | 669 | errno = EXDEV; \ |
… |
… |
|
671 | 677 | if (result == -1) \ |
672 | 678 | errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ |
673 | 679 | return result; \ |
674 | | } else { \ |
675 | | g_free (name1); \ |
676 | | return -1; \ |
677 | | } \ |
678 | | } else return -1; \ |
679 | 680 | } |
680 | 681 | |
681 | 682 | MC_RENAMEOP (link) |
… |
… |
|
704 | 705 | vfs_die("You don't want to pass NULL to mc_setctl."); |
705 | 706 | |
706 | 707 | mpath = vfs_canon_and_translate (path); |
707 | | if (mpath != NULL) { |
| 708 | if (mpath == NULL) |
| 709 | return -1; |
| 710 | |
708 | 711 | vfs = vfs_get_class (mpath); |
709 | 712 | result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0; |
710 | 713 | g_free (mpath); |
711 | 714 | return result; |
712 | | } else return -1; |
713 | 715 | } |
714 | 716 | |
715 | 717 | int |
… |
… |
|
752 | 754 | canon = vfs_canon (dirname); |
753 | 755 | dname = vfs_translate_path_n (canon); |
754 | 756 | |
755 | | if (dname != NULL) { |
| 757 | if (dname == NULL) { |
| 758 | g_free (canon); |
| 759 | return NULL; |
| 760 | } |
756 | 761 | vfs = vfs_get_class (dname); |
757 | 762 | info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL; |
758 | 763 | g_free (dname); |
… |
… |
|
777 | 782 | handlep = g_new (int, 1); |
778 | 783 | *handlep = handle; |
779 | 784 | return (DIR *) handlep; |
780 | | } else { |
781 | | g_free (canon); |
782 | | return NULL; |
783 | | } |
784 | 785 | } |
785 | 786 | |
786 | 787 | static struct dirent * mc_readdir_result = NULL; |
… |
… |
|
1070 | 1071 | |
1071 | 1072 | new_dir = vfs_canon (path); |
1072 | 1073 | trans_dir = vfs_translate_path_n (new_dir); |
1073 | | if (trans_dir != NULL) { |
1074 | | new_vfs = vfs_get_class (trans_dir); |
| 1074 | if (trans_dir == NULL) { |
| 1075 | g_free (new_dir); |
| 1076 | return -1; |
| 1077 | } |
| 1078 | new_vfs = vfs_get_class (trans_dir); |
1075 | 1079 | if (!new_vfs->chdir) { |
1076 | 1080 | g_free (new_dir); |
1077 | 1081 | g_free (trans_dir); |
… |
… |
|
1108 | 1112 | |
1109 | 1113 | g_free (trans_dir); |
1110 | 1114 | return 0; |
1111 | | } else { |
1112 | | g_free (new_dir); |
1113 | | return -1; |
1114 | | } |
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /* Return 1 is the current VFS class is local */ |
… |
… |
|
1129 | 1129 | char *fname; |
1130 | 1130 | |
1131 | 1131 | fname = vfs_canon_and_translate (filename); |
1132 | | if (fname != NULL) { |
| 1132 | if (fname == NULL) |
| 1133 | return -1; |
| 1134 | |
1133 | 1135 | vfs = vfs_get_class (fname); |
1134 | 1136 | g_free (fname); |
1135 | 1137 | return vfs->flags; |
1136 | | } else return -1; |
1137 | 1138 | } |
1138 | 1139 | |
1139 | 1140 | static char * |
… |
… |
|
1187 | 1188 | { |
1188 | 1189 | char *result; |
1189 | 1190 | char *path; |
| 1191 | struct vfs_class *vfs; |
1190 | 1192 | |
1191 | 1193 | path = vfs_canon_and_translate (pathname); |
1192 | | if (path != NULL) { |
1193 | | struct vfs_class *vfs = vfs_get_class (path); |
| 1194 | if (path == NULL) |
| 1195 | return NULL; |
| 1196 | |
| 1197 | vfs = vfs_get_class (path); |
1194 | 1198 | |
1195 | 1199 | result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) : |
1196 | 1200 | mc_def_getlocalcopy (path); |
… |
… |
|
1198 | 1202 | if (!result) |
1199 | 1203 | errno = ferrno (vfs); |
1200 | 1204 | return result; |
1201 | | } else return NULL; |
1202 | 1205 | } |
1203 | 1206 | |
1204 | 1207 | static int |
… |
… |
|
1253 | 1256 | { |
1254 | 1257 | int return_value = 0; |
1255 | 1258 | char *path; |
| 1259 | struct vfs_class *vfs; |
1256 | 1260 | |
1257 | 1261 | path = vfs_canon_and_translate (pathname); |
1258 | | if (path != NULL) { |
1259 | | struct vfs_class *vfs = vfs_get_class (path); |
| 1262 | if (path == NULL) |
| 1263 | return -1; |
| 1264 | |
| 1265 | vfs = vfs_get_class (path); |
1260 | 1266 | |
1261 | 1267 | return_value = vfs->ungetlocalcopy ? |
1262 | 1268 | (*vfs->ungetlocalcopy)(vfs, path, local, has_changed) : |
1263 | 1269 | mc_def_ungetlocalcopy (vfs, path, local, has_changed); |
1264 | 1270 | g_free (path); |
1265 | 1271 | return return_value; |
1266 | | } else return -1; |
1267 | 1272 | } |
1268 | 1273 | |
1269 | 1274 | |