オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Diff of /trunk/1.7.x/ccs-patch/security/ccsecurity/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2037 by kumaneko, Mon Jan 5 05:56:56 2009 UTC revision 2039 by kumaneko, Wed Jan 7 04:42:05 2009 UTC
# Line 564  void ccs_fill_path_info(struct ccs_path_ Line 564  void ccs_fill_path_info(struct ccs_path_
564  }  }
565    
566  /**  /**
567   * ccs_file_matches_to_pattern2 - Pattern matching without '/' character   * ccs_file_matches_pattern2 - Pattern matching without '/' character
568   * and "\-" pattern.   * and "\-" pattern.
569   *   *
570   * @filename:     The start of string to check.   * @filename:     The start of string to check.
# Line 574  void ccs_fill_path_info(struct ccs_path_ Line 574  void ccs_fill_path_info(struct ccs_path_
574   *   *
575   * Returns true if @filename matches @pattern, false otherwise.   * Returns true if @filename matches @pattern, false otherwise.
576   */   */
577  static bool ccs_file_matches_to_pattern2(const char *filename,  static bool ccs_file_matches_pattern2(const char *filename,
578                                           const char *filename_end,                                        const char *filename_end,
579                                           const char *pattern,                                        const char *pattern,
580                                           const char *pattern_end)                                        const char *pattern_end)
581  {  {
582          while (filename < filename_end && pattern < pattern_end) {          while (filename < filename_end && pattern < pattern_end) {
583                  char c;                  char c;
# Line 635  static bool ccs_file_matches_to_pattern2 Line 635  static bool ccs_file_matches_to_pattern2
635                  case '*':                  case '*':
636                  case '@':                  case '@':
637                          for (i = 0; i <= filename_end - filename; i++) {                          for (i = 0; i <= filename_end - filename; i++) {
638                                  if (ccs_file_matches_to_pattern2(filename + i,                                  if (ccs_file_matches_pattern2(filename + i,
639                                                                   filename_end,                                                                filename_end,
640                                                                   pattern + 1,                                                                pattern + 1,
641                                                                   pattern_end))                                                                pattern_end))
642                                          return true;                                          return true;
643                                  c = filename[i];                                  c = filename[i];
644                                  if (c == '.' && *pattern == '@')                                  if (c == '.' && *pattern == '@')
# Line 667  static bool ccs_file_matches_to_pattern2 Line 667  static bool ccs_file_matches_to_pattern2
667                                          j++;                                          j++;
668                          }                          }
669                          for (i = 1; i <= j; i++) {                          for (i = 1; i <= j; i++) {
670                                  if (ccs_file_matches_to_pattern2(filename + i,                                  if (ccs_file_matches_pattern2(filename + i,
671                                                                   filename_end,                                                                filename_end,
672                                                                   pattern + 1,                                                                pattern + 1,
673                                                                   pattern_end))                                                                pattern_end))
674                                          return true;                                          return true;
675                          }                          }
676                          return false; /* Not matched or bad pattern. */                          return false; /* Not matched or bad pattern. */
# Line 685  static bool ccs_file_matches_to_pattern2 Line 685  static bool ccs_file_matches_to_pattern2
685  }  }
686    
687  /**  /**
688   * ccs_file_matches_to_pattern - Pattern matching without without '/' character.   * ccs_file_matches_pattern - Pattern matching without without '/' character.
689   *   *
690   * @filename:     The start of string to check.   * @filename:     The start of string to check.
691   * @filename_end: The end of string to check.   * @filename_end: The end of string to check.
# Line 694  static bool ccs_file_matches_to_pattern2 Line 694  static bool ccs_file_matches_to_pattern2
694   *   *
695   * Returns true if @filename matches @pattern, false otherwise.   * Returns true if @filename matches @pattern, false otherwise.
696   */   */
697  static bool ccs_file_matches_to_pattern(const char *filename,  static bool ccs_file_matches_pattern(const char *filename,
698                                          const char *filename_end,                                       const char *filename_end,
699                                          const char *pattern,                                       const char *pattern,
700                                          const char *pattern_end)                                       const char *pattern_end)
701  {  {
702          const char *pattern_start = pattern;          const char *pattern_start = pattern;
703          bool first = true;          bool first = true;
# Line 706  static bool ccs_file_matches_to_pattern( Line 706  static bool ccs_file_matches_to_pattern(
706                  /* Split at "\-" pattern. */                  /* Split at "\-" pattern. */
707                  if (*pattern++ != '\\' || *pattern++ != '-')                  if (*pattern++ != '\\' || *pattern++ != '-')
708                          continue;                          continue;
709                  result = ccs_file_matches_to_pattern2(filename, filename_end,                  result = ccs_file_matches_pattern2(filename, filename_end,
710                                                        pattern_start,                                                     pattern_start,
711                                                        pattern - 2);                                                     pattern - 2);
712                  if (first)                  if (first)
713                          result = !result;                          result = !result;
714                  if (result)                  if (result)
# Line 716  static bool ccs_file_matches_to_pattern( Line 716  static bool ccs_file_matches_to_pattern(
716                  first = false;                  first = false;
717                  pattern_start = pattern;                  pattern_start = pattern;
718          }          }
719          result = ccs_file_matches_to_pattern2(filename, filename_end,          result = ccs_file_matches_pattern2(filename, filename_end,
720                                                pattern_start, pattern_end);                                             pattern_start, pattern_end);
721          return first ? result : !result;          return first ? result : !result;
722  }  }
723    
# Line 771  bool ccs_path_matches_pattern(const stru Line 771  bool ccs_path_matches_pattern(const stru
771                          f_delimiter = f + strlen(f);                          f_delimiter = f + strlen(f);
772                  if (!p_delimiter)                  if (!p_delimiter)
773                          p_delimiter = p + strlen(p);                          p_delimiter = p + strlen(p);
774                  if (!ccs_file_matches_to_pattern(f, f_delimiter,                  if (!ccs_file_matches_pattern(f, f_delimiter,
775                                                   p, p_delimiter))                                                p, p_delimiter))
776                          return false;                          return false;
777                  f = f_delimiter;                  f = f_delimiter;
778                  if (*f)                  if (*f)

Legend:
Removed from v.2037  
changed lines
  Added in v.2039

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26