Print this page
6645 sgsmsg relies on undefined behaviour of loop-scoped variables

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/tools/common/sgsmsg.c
          +++ new/usr/src/cmd/sgs/tools/common/sgsmsg.c
↓ open down ↓ 657 lines elided ↑ open up ↑
 658  658          return (0);
 659  659  }
 660  660  
 661  661  static int
 662  662  file()
 663  663  {
 664  664          char    buffer[LINE_MAX], * token;
 665  665          uint_t  bufsize;
 666  666          char    *token_buffer;
 667  667          int     escape = 0;
      668 +        int     len = 0;
 668  669  
 669  670          if ((token_buffer = malloc(LINE_MAX)) == 0) {
 670  671                  (void) fprintf(stderr, Errmsg_nmem, strerror(errno));
 671  672                  return (1);
 672  673          }
 673  674          bufsize = LINE_MAX;
 674  675  
 675  676          line = 1;
 676  677  
 677  678          while ((token = fgets(buffer, LINE_MAX, fddesc)) != NULL) {
 678  679                  char    defn[PATH_MAX], * _defn, * str;
 679      -                int     len;
 680  680  
 681  681                  switch (*token) {
 682  682                  case '#':
 683  683                  case '$':
 684  684                          if (escape) {
 685  685                                  (void) fprintf(stderr, Errmsg_malt, fldesc,
 686  686                                      line);
 687  687                                  return (1);
 688  688                          }
 689  689  
↓ open down ↓ 548 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX