CVE-2016-0546 (C, published 2016-01-21T03:01Z)
Description: value: Unspecified vulnerability in Oracle MySQL 5.5.46 and earlier, 5.6.27 and earlier, and 5.7.9 and MariaDB before 5.5.47, 10.0.x before 10.0.23, and 10.1.x before 10.1.10 allows local users to affect confidentiality, integrity, and availability via unknown vectors related to Client.  NOTE: the previous information is from the January 2016 CPU. Oracle has not commented on third-party claims that these are multiple buffer overflows in the mysqlshow tool that allow remote database servers to have unspecified impact via a long table or database name.
Severity: HIGH (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/mysql/mysql-server
Files changed:
client/mysql_plugin.c
client/mysqlshow.c
libmysql/conf_to_src.c
regex/main.c
Commit message: Bug#21973610: BUFFER OVERFLOW ISSUES

Description : Incorrect usage of sprintf/strcpy caused
              possible buffer overflow issues at various
              places.

Solution : - Fixed mysql_plugin and mysqlshow
           - Fixed regex library issues

Reviewed-By : Georgi Kodinov <georgi.kodinov@oracle.com>
Reviewed-By : Venkata S Murthy Sidagam <venkata.sidagam@oracle.com>


Vulnerable code:
   Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  puts("Copyright (c) 2011, Oracle and/or its affiliates. "
  char query[255];
	      sprintf(query,"SELECT COUNT(*) FROM `%s`",trow[0]);
  char query[255], rows[NAME_LEN], fields[16];
	    sprintf(query,"SELECT COUNT(*) FROM `%s`",row[0]);
  char query[1024],*end;
  end=strxmov(query,"show table status from `",db,"`",NullS);
  if (wild && wild[0])
    strxmov(end," like '",wild,"'",NullS);
  char query[1024],*end;
    sprintf(query,"select count(*) from `%s`", table);
  end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`");
  if (wild && wild[0])
    strxmov(end," like '",wild,"'",NullS);
    end=strmov(strmov(strmov(query,"show keys from `"),table),"`");
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  sprintf(buf, "%s.conf", set);
		sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
		sprintf(grump, "start %ld end %ld, past end of string",
		sprintf(grump, "matched `%.*s'", len, p);
		sprintf(grump, "matched `%.*s' instead", len, p);
		sprintf(grump, "matched null at `%.20s'", p);
	sprintf(efbuf, "REG_%s", name);

Fixed code:
   Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
  puts("Copyright (c) 2011, 2015, Oracle and/or its affiliates. "
      if (strlen(argv[i]) + 4 + 1 > FN_REFLEN)
      {
        fprintf(stderr, "ERROR: argument is too long.\n");
        return 1;
      }
      memset(buff, 0, sizeof(buff));
  char query[NAME_LEN + 100];
              my_snprintf(query, sizeof(query),
                          "SELECT COUNT(*) FROM `%s`", trow[0]);
  char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
            my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM `%s`",
                        row[0]);
  char query[NAME_LEN + 100];
  int len;
  len= sizeof(query);
  len-= my_snprintf(query, len, "show table status from `%s`", db);
  if (wild && wild[0] && len)
    strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
  char query[NAME_LEN + 100];
  int len;
    my_snprintf(query, sizeof(query), "select count(*) from `%s`", table);
  len= sizeof(query);
  len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
                    table);
  if (wild && wild[0] && len)
    strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
    my_snprintf(query, sizeof(query), "show keys from `%s`", table);
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  snprintf(buf, sizeof(buf), "%s.conf", set);
		snprintf(grump, sizeof(grump),
			 "start %ld end %ld", (long)sub.rm_so,
		snprintf(grump, sizeof(grump),
			 "start %ld end %ld, past end of string",
		snprintf(grump, sizeof(grump),
			 "matched `%.*s'", len, p);
		snprintf(grump, sizeof(grump),
			 "matched `%.*s' instead", len, p);
		snprintf(grump, sizeof(grump),
			 "matched null at `%.20s'", p);
	snprintf(efbuf, sizeof(efbuf), "REG_%s", name);