diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:40:30 +0700 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:40:30 +0700 |
commit | 3b5c308768d76298bb964814ecc34de47bcac0b4 (patch) | |
tree | 795340e9d8f5e5bf9e8d895641099af343eec2a0 /findutils | |
parent | 2b9a0e715ec459198f486653023d963b79291da7 (diff) | |
parent | 5fe2f863b9cee5ab0e7ac873538bce48846dbad8 (diff) | |
download | busybox-w32-3b5c308768d76298bb964814ecc34de47bcac0b4.tar.gz busybox-w32-3b5c308768d76298bb964814ecc34de47bcac0b4.tar.bz2 busybox-w32-3b5c308768d76298bb964814ecc34de47bcac0b4.zip |
Merge commit '06f719fd79fe15ce6fd5431bc58fcb22851de24d^'
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/.gitignore | 3 | ||||
-rw-r--r-- | findutils/grep.c | 15 |
2 files changed, 9 insertions, 9 deletions
diff --git a/findutils/.gitignore b/findutils/.gitignore deleted file mode 100644 index 7a30caf5c..000000000 --- a/findutils/.gitignore +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | # Config.in and Kbuild are auto-generated | ||
2 | Config.in | ||
3 | Kbuild | ||
diff --git a/findutils/grep.c b/findutils/grep.c index bf42753c5..f166aa48a 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -629,30 +629,33 @@ int grep_main(int argc UNUSED_PARAM, char **argv) | |||
629 | 629 | ||
630 | /* do normal option parsing */ | 630 | /* do normal option parsing */ |
631 | #if ENABLE_FEATURE_GREP_CONTEXT | 631 | #if ENABLE_FEATURE_GREP_CONTEXT |
632 | int Copt; | 632 | int Copt, opts; |
633 | 633 | ||
634 | /* -H unsets -h; -C unsets -A,-B; -e,-f are lists; | 634 | /* -H unsets -h; -C unsets -A,-B; -e,-f are lists; |
635 | * -m,-A,-B,-C have numeric param */ | 635 | * -m,-A,-B,-C have numeric param */ |
636 | opt_complementary = "H-h:C-AB:e::f::m+:A+:B+:C+"; | 636 | opt_complementary = "H-h:C-AB:e::f::m+:A+:B+:C+"; |
637 | getopt32(argv, | 637 | opts = getopt32(argv, |
638 | OPTSTR_GREP, | 638 | OPTSTR_GREP, |
639 | &pattern_head, &fopt, &max_matches, | 639 | &pattern_head, &fopt, &max_matches, |
640 | &lines_after, &lines_before, &Copt); | 640 | &lines_after, &lines_before, &Copt); |
641 | 641 | ||
642 | if (option_mask32 & OPT_C) { | 642 | if (opts & OPT_C) { |
643 | /* -C unsets prev -A and -B, but following -A or -B | 643 | /* -C unsets prev -A and -B, but following -A or -B |
644 | may override it */ | 644 | may override it */ |
645 | if (!(option_mask32 & OPT_A)) /* not overridden */ | 645 | if (!(opts & OPT_A)) /* not overridden */ |
646 | lines_after = Copt; | 646 | lines_after = Copt; |
647 | if (!(option_mask32 & OPT_B)) /* not overridden */ | 647 | if (!(opts & OPT_B)) /* not overridden */ |
648 | lines_before = Copt; | 648 | lines_before = Copt; |
649 | } | 649 | } |
650 | /* sanity checks */ | 650 | /* sanity checks */ |
651 | if (option_mask32 & (OPT_c|OPT_q|OPT_l|OPT_L)) { | 651 | if (opts & (OPT_c|OPT_q|OPT_l|OPT_L)) { |
652 | option_mask32 &= ~OPT_n; | 652 | option_mask32 &= ~OPT_n; |
653 | lines_before = 0; | 653 | lines_before = 0; |
654 | lines_after = 0; | 654 | lines_after = 0; |
655 | } else if (lines_before > 0) { | 655 | } else if (lines_before > 0) { |
656 | if (lines_before > INT_MAX / sizeof(long long)) | ||
657 | lines_before = INT_MAX / sizeof(long long); | ||
658 | /* overflow in (lines_before * sizeof(x)) is prevented (above) */ | ||
656 | before_buf = xzalloc(lines_before * sizeof(before_buf[0])); | 659 | before_buf = xzalloc(lines_before * sizeof(before_buf[0])); |
657 | IF_EXTRA_COMPAT(before_buf_size = xzalloc(lines_before * sizeof(before_buf_size[0]));) | 660 | IF_EXTRA_COMPAT(before_buf_size = xzalloc(lines_before * sizeof(before_buf_size[0]));) |
658 | } | 661 | } |