Print this page
10323 cpcgen_parse_model() gets value check wrong

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/cpcgen/cpcgen.c
          +++ new/usr/src/tools/cpcgen/cpcgen.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright (c) 2018, Joyent, Inc.
       13 + * Copyright (c) 2019, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * This file transforms the perfmon data files into C files and manual pages.
  18   18   */
  19   19  
  20   20  #include <stdio.h>
  21   21  #include <stdarg.h>
  22   22  #include <unistd.h>
  23   23  #include <err.h>
↓ open down ↓ 286 lines elided ↑ open up ↑
 310  310                  errx(EXIT_FAILURE, "failed to parse processor id \"%s\"", fsr);
 311  311          }
 312  312  
 313  313          if (strcmp(bstr, brand) != 0) {
 314  314                  errx(EXIT_FAILURE, "brand string \"%s\" did not match \"%s\"",
 315  315                      brand, bstr);
 316  316          }
 317  317  
 318  318          errno = 0;
 319  319          l = strtol(fam, &last, 16);
 320      -        if (errno != 0 || l < 0 || l > UINT_MAX || *last != '\0') {
      320 +        if (errno != 0 || l < 0 || l >= INT_MAX || *last != '\0') {
 321  321                  errx(EXIT_FAILURE, "failed to parse family \"%s\"", fam);
 322  322          }
 323  323          *family = (uint_t)l;
 324  324  
 325  325          l = strtol(mod, &last, 16);
 326      -        if (errno != 0 || l < 0 || l > UINT_MAX || *last != '\0') {
      326 +        if (errno != 0 || l < 0 || l >= INT_MAX || *last != '\0') {
 327  327                  errx(EXIT_FAILURE, "failed to parse model \"%s\"", mod);
 328  328          }
 329  329          *model = (uint_t)l;
 330  330  }
 331  331  
 332  332  static nvlist_t *
 333  333  cpcgen_read_datafile(const char *datadir, const char *file)
 334  334  {
 335  335          int fd;
 336  336          char *path;
↓ open down ↓ 954 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX