Print this page
7214 make buffer under-read while parsing conditional variables
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/doname.cc
          +++ new/usr/src/cmd/make/bin/doname.cc
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2016 RackTop Systems.
  24   26   */
  25   27  
  26   28  /*
  27   29   *      doname.c
  28   30   *
  29   31   *      Figure out which targets are out of date and rebuild them
  30   32   */
  31   33  
  32   34  /*
  33   35   * Included files
↓ open down ↓ 2852 lines elided ↑ open up ↑
2886 2888          Wstring wcb(target);
2887 2889          Wstring wcb1;
2888 2890  
2889 2891          for (conditional = get_prop(conditionals->prop, conditional_prop);
2890 2892               conditional != NULL;
2891 2893               conditional = get_prop(conditional->next, conditional_prop)) {
2892 2894                  wcb1.init(conditional->body.conditional.target);
2893 2895                  pattern = wcb1.get_string();
2894 2896                  if (pattern[1] != 0) {
2895 2897                          percent = (wchar_t *) wcschr(pattern, (int) percent_char);
     2898 +                        /* Check for possible buffer under-read */
     2899 +                        if ((length = wcb.length()-wcslen(percent+1)) <= 0) {
     2900 +                                continue;
     2901 +                        }
2896 2902                          if (!wcb.equaln(pattern, percent-pattern) ||
2897      -                            !IS_WEQUAL(wcb.get_string(wcb.length()-wcslen(percent+1)), percent+1)) {
     2903 +                            !IS_WEQUAL(wcb.get_string(length), percent+1)) {
2898 2904                                  continue;
2899 2905                          }
2900 2906                  }
2901 2907                  for (previous = &target->prop;
2902 2908                       *previous != NULL;
2903 2909                       previous = &(*previous)->next) {
2904 2910                          if (((*previous)->type == conditional_prop) &&
2905 2911                              ((*previous)->body.conditional.sequence >
2906 2912                               conditional->body.conditional.sequence)) {
2907 2913                                  break;
↓ open down ↓ 296 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX