Print this page
smatch clean rtld

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/rtld/common/util.c
          +++ new/usr/src/cmd/sgs/rtld/common/util.c
↓ open down ↓ 388 lines elided ↑ open up ↑
 389  389                  /*
 390  390                   * We better not get a hit now, we do not want duplicates in
 391  391                   * the tree.
 392  392                   */
 393  393                  ASSERT(_lmp == NULL);
 394  394          }
 395  395  
 396  396          /*
 397  397           * Insert new node in tree.
 398  398           */
 399      -        if ((fpnp = calloc(sizeof (FullPathNode), 1)) == NULL)
      399 +        if ((fpnp = calloc(1, sizeof (FullPathNode))) == NULL)
 400  400                  return (0);
 401  401  
 402  402          fpnp->fpn_node.pn_name = name;
 403  403          fpnp->fpn_node.pn_hash = hash;
 404  404          fpnp->fpn_lmp = lmp;
 405  405  
 406  406          if (aplist_append(&FPNODE(lmp), fpnp, AL_CNT_FPNODE) == NULL) {
 407  407                  free(fpnp);
 408  408                  return (0);
 409  409          }
↓ open down ↓ 42 lines elided ↑ open up ↑
 452  452                  /*
 453  453                   * We better not get a hit now, we do not want duplicates in
 454  454                   * the tree.
 455  455                   */
 456  456                  ASSERT(in_nfavl == 0);
 457  457          }
 458  458  
 459  459          /*
 460  460           * Insert new node in tree.
 461  461           */
 462      -        if ((pnp = calloc(sizeof (PathNode), 1)) != NULL) {
      462 +        if ((pnp = calloc(1, sizeof (PathNode))) != NULL) {
 463  463                  pnp->pn_name = name;
 464  464                  pnp->pn_hash = hash;
 465  465                  avl_insert(nfavl, pnp, where);
 466  466          }
 467  467  }
 468  468  
 469  469  /*
 470  470   * Insert the directory name, of a full path name, into the secure path AVL
 471  471   * tree.
 472  472   *
↓ open down ↓ 26 lines elided ↑ open up ↑
 499  499          /*
 500  500           * Determine whether this directory name is already recorded, or if
 501  501           * not, 'where" will provide the insertion point for the new string.
 502  502           */
 503  503          if (pnavl_recorded(&spavl, buffer, hash, &where))
 504  504                  return;
 505  505  
 506  506          /*
 507  507           * Insert new node in tree.
 508  508           */
 509      -        if ((pnp = calloc(sizeof (PathNode), 1)) != NULL) {
      509 +        if ((pnp = calloc(1, sizeof (PathNode))) != NULL) {
 510  510                  pnp->pn_name = strdup(buffer);
 511  511                  pnp->pn_hash = hash;
 512  512                  avl_insert(spavl, pnp, where);
 513  513          }
 514  514  }
 515  515  
 516  516  /*
 517  517   * Inspect the generic string AVL tree for the given string.  If the string is
 518  518   * not present, duplicate it, and insert the string in the AVL tree.  Return the
 519  519   * duplicated string to the caller.
↓ open down ↓ 2361 lines elided ↑ open up ↑
2881 2881   * The RT_FL_APPLIC flag serves to indicate the transition between process
2882 2882   * initialization and when the applications code is running.
2883 2883   */
2884 2884  void
2885 2885  veprintf(Lm_list *lml, Error error, const char *format, va_list args)
2886 2886  {
2887 2887          int             overflow = 0;
2888 2888          static int      lock = 0;
2889 2889          Prfbuf          prf;
2890 2890  
2891      -        if (lock || (nextptr == (errbuf + ERRSIZE)))
     2891 +        if (lock || (nextptr > (errbuf + (ERRSIZE - 1))))
2892 2892                  return;
2893 2893  
2894 2894          /*
2895 2895           * Note: this lock is here to prevent the same thread from recursively
2896 2896           * entering itself during a eprintf.  ie: during eprintf malloc() fails
2897 2897           * and we try and call eprintf ... and then malloc() fails ....
2898 2898           */
2899 2899          lock = 1;
2900 2900  
2901 2901          /*
↓ open down ↓ 217 lines elided ↑ open up ↑
3119 3119  
3120 3120                                  while ((errptr < errend) && *errptr) {
3121 3121                                          size_t  size = strlen(errptr);
3122 3122                                          (void) write(2, errptr, size);
3123 3123                                          (void) write(2, MSG_ORIG(MSG_STR_NL),
3124 3124                                              MSG_STR_NL_SIZE);
3125 3125                                          errptr += (size + 1);
3126 3126                                  }
3127 3127                          }
3128 3128                          if (lasterr && ((lasterr < errbuf) ||
3129      -                            (lasterr > (errbuf + ERRSIZE)))) {
     3129 +                            (lasterr > (errbuf + (ERRSIZE - 1))))) {
3130 3130                                  (void) write(2, lasterr, strlen(lasterr));
3131 3131                                  (void) write(2, MSG_ORIG(MSG_STR_NL),
3132 3132                                      MSG_STR_NL_SIZE);
3133 3133                          }
3134 3134                  }
3135 3135                  leave(lml, 0);
3136 3136                  (void) _lwp_kill(_lwp_self(), killsig);
3137 3137          }
3138 3138          _exit(status);
3139 3139  }
↓ open down ↓ 649 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX