| 702 | } |
| 703 | |
| 704 | static inline void call_glob_match(const char *name, int len, int from_glob, |
| 705 | char *arg, int abpos, int fbpos) |
| 706 | { |
| 707 | char *use_buf; |
| 708 | |
| 709 | ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, abpos + len + 2); |
| 710 | memcpy(glob.arg_buf + abpos, name, len); |
| 711 | abpos += len; |
| 712 | glob.arg_buf[abpos] = '\0'; |
| 713 | |
| 714 | if (fbpos >= 0) { |
| 715 | ENSURE_MEMSPACE(glob.filt_buf, char, glob.fbsize, fbpos + len + 2); |
| 716 | memcpy(glob.filt_buf + fbpos, name, len); |
| 717 | fbpos += len; |
| 718 | glob.filt_buf[fbpos] = '\0'; |
| 719 | use_buf = glob.filt_buf; |
| 720 | } else |
| 721 | use_buf = glob.arg_buf; |
| 722 | |
| 723 | if (from_glob || (arg && len)) { |
| 724 | STRUCT_STAT st; |
| 725 | int is_dir; |
| 726 | |
| 727 | if (do_stat(glob.arg_buf, &st) != 0) |
| 728 | return; |
| 729 | is_dir = S_ISDIR(st.st_mode) != 0; |
| 730 | if (arg && !is_dir) |
| 731 | return; |
| 732 | |
| 733 | if (daemon_filter_list.head |
| 734 | && check_filter(&daemon_filter_list, FLOG, use_buf, is_dir) < 0) |
| 735 | return; |
| 736 | } |
| 737 | |
| 738 | if (arg) { |
| 739 | glob.arg_buf[abpos++] = '/'; |
| 740 | glob.arg_buf[abpos] = '\0'; |
| 741 | if (fbpos >= 0) { |
| 742 | glob.filt_buf[fbpos++] = '/'; |
| 743 | glob.filt_buf[fbpos] = '\0'; |
| 744 | } |
| 745 | glob_match(arg, abpos, fbpos); |
| 746 | } else { |
| 747 | ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, glob.argc + 1); |
| 748 | glob.argv[glob.argc++] = strdup(glob.arg_buf); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /* This routine performs wild-card expansion of the pathname in "arg". Any |
| 753 | * daemon-excluded files/dirs will not be matched by the wildcards. Returns 0 |
no test coverage detected