Print this page
10088 ldterm_do_ioctl() shouldn't check for a NULL array

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ldterm.c
          +++ new/usr/src/uts/common/io/ldterm.c
↓ 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 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24      - * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
       24 + * Copyright (c) 2018, Joyent, Inc.
  25   25   * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  26   26   */
  27   27  
  28   28  /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T      */
  29   29  /* All Rights Reserved                                  */
  30   30  
  31   31  /*
  32   32   * University Copyright- Copyright (c) 1982, 1986, 1988
  33   33   * The Regents of the University of California
  34   34   * All Rights Reserved
↓ open down ↓ 4557 lines elided ↑ open up ↑
4592 4592                                      maxscreenlen)
4593 4593                                          maxscreenlen =
4594 4594                                              csdp->eucpc_data[i].screen_width;
4595 4595                          }
4596 4596                  } else if (csdp->codeset_type == LDTERM_CS_TYPE_UTF8) {
4597 4597                          maxbytelen = 4;
4598 4598                          maxscreenlen = 2;
4599 4599                  }
4600 4600  
4601 4601                  locale_name_sz = 0;
4602      -                if (csdp->locale_name) {
4603      -                        for (i = 0; i < MAXNAMELEN; i++)
4604      -                                if (csdp->locale_name[i] == '\0')
4605      -                                        break;
4606      -                        /*
4607      -                         * We cannot have any string that is not NULL byte
4608      -                         * terminated.
4609      -                         */
4610      -                        if (i >= MAXNAMELEN) {
4611      -                                miocnak(q, mp, 0, ERANGE);
4612      -                                return;
4613      -                        }
4614 4602  
4615      -                        locale_name_sz = i + 1;
     4603 +                for (i = 0; i < MAXNAMELEN; i++)
     4604 +                        if (csdp->locale_name[i] == '\0')
     4605 +                                break;
     4606 +                /*
     4607 +                 * We cannot have any string that is not NULL byte
     4608 +                 * terminated.
     4609 +                 */
     4610 +                if (i >= MAXNAMELEN) {
     4611 +                        miocnak(q, mp, 0, ERANGE);
     4612 +                        return;
4616 4613                  }
4617 4614  
     4615 +                locale_name_sz = i + 1;
     4616 +
4618 4617                  /*
4619 4618                   * As the final check, if there was invalid codeset_type
4620 4619                   * given, or invalid byte_length was specified, it's an error.
4621 4620                   */
4622 4621                  if (maxbytelen <= 0 || maxscreenlen <= 0) {
4623 4622                          miocnak(q, mp, 0, ERANGE);
4624 4623                          return;
4625 4624                  }
4626 4625  
4627 4626                  /* Do the switching. */
↓ open down ↓ 899 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX