Print this page
11472 fix libdemangle rust changes

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdemangle/common/rust.c
          +++ new/usr/src/lib/libdemangle/common/rust.c
↓ open down ↓ 231 lines elided ↑ open up ↑
 232  232          sv_init_sv(&sv, svp);
 233  233  
 234  234          if (!rustdem_parse_num(st, &sv, &len)) {
 235  235                  DEMDEBUG("ERROR: no leading length");
 236  236                  st->rds_error = EINVAL;
 237  237                  return (B_FALSE);
 238  238          }
 239  239  
 240  240          rem = sv_remaining(&sv);
 241  241  
 242      -        if (rem < len || len == SIZE_MAX) {
      242 +        if (rem < len) {
 243  243                  st->rds_error = EINVAL;
 244  244                  return (B_FALSE);
 245  245          }
 246  246  
 247  247          /* Is this the last segment before the terminating E? */
 248  248          if (rem == len + 1) {
 249  249                  VERIFY3U(sv_peek(&sv, -1), ==, 'E');
 250  250                  last = B_TRUE;
 251  251          }
 252  252  
↓ open down ↓ 124 lines elided ↑ open up ↑
 377  377                  default:
 378  378                          return (B_FALSE);
 379  379                  }
 380  380          }
 381  381  
 382  382          sv_init_sv(svp, &sv);
 383  383          return (B_TRUE);
 384  384  }
 385  385  
 386  386  /*
 387      - * A 10 digit value would imply a name 1Gb or larger in size.  It seems
 388      - * unlikely to the point of absurdity any such value could every possibly
 389      - * be valid (or even have compiled properly).  This also prevents the
 390      - * uint64_t conversion from possibly overflowing since the value must always
 391      - * be below 10 * UINT32_MAX.
      387 + * We have to pick an arbitrary limit here; 999,999,999 fits comfortably
      388 + * within an int32_t, so let's go with that, as it seems unlikely we'd
      389 + * ever see a larger value in context.
 392  390   */
 393      -#define MAX_DIGITS 10
      391 +#define MAX_DIGITS 9
 394  392  
 395  393  static boolean_t
 396  394  rustdem_parse_num(rustdem_state_t *restrict st, strview_t *restrict svp,
 397  395      uint64_t *restrict valp)
 398  396  {
 399  397          strview_t snum;
 400  398          uint64_t v = 0;
 401  399          size_t ndigits = 0;
 402  400          char c;
 403  401  
↓ open down ↓ 140 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX