Commit 8a56af76 authored by unknown's avatar unknown

Fix for bug #23810: Server crashes on various "show status ..." commands

We access some variable values using casts like *(long *) buff
that may cause crashes on some platforms (e.g. solaris 64) if buff is
not properly aligned.
Fix: align the buffer used.


include/my_global.h:
  Fix for bug #23810: Server crashes on various "show status ..." commands
    - MY_DIV_UP(A, B) macro introduced, which devides A then rounds up by B.
    - MY_ALIGNED_BYTE_ARRAY(N, S, T) macro introduced, which declares an S-byte long
      (aligned) N array of type T.
sql/sql_show.cc:
  Fix for bug #23810: Server crashes on various "show status ..." commands
    - align the buffer used.
parent 1269a52d
...@@ -911,6 +911,9 @@ typedef unsigned long long my_size_t; ...@@ -911,6 +911,9 @@ typedef unsigned long long my_size_t;
#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
/* /*
Custom version of standard offsetof() macro which can be used to get Custom version of standard offsetof() macro which can be used to get
offsets of members in class for non-POD types (according to the current offsets of members in class for non-POD types (according to the current
......
...@@ -2035,7 +2035,9 @@ static bool show_status_array(THD *thd, const char *wild, ...@@ -2035,7 +2035,9 @@ static bool show_status_array(THD *thd, const char *wild,
const char *prefix, TABLE *table, const char *prefix, TABLE *table,
bool ucase_names) bool ucase_names)
{ {
char buff[SHOW_VAR_FUNC_BUFF_SIZE], *prefix_end; MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long);
char * const buff= (char *) &buff_data;
char *prefix_end;
/* the variable name should not be longer than 64 characters */ /* the variable name should not be longer than 64 characters */
char name_buffer[64]; char name_buffer[64];
int len; int len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment