Skip to content

Commit be372e5

Browse files
committed
merge of 5.1-bugteam into 5.1-security
--BZR-- revision-id: [email protected] property-branch-nick: merge-5.1-security testament3-sha1: b638ce71d8a97434f26d67157e134e82e2584f0f
2 parents cf5c5cf + e28ad6f commit be372e5

File tree

149 files changed

+3837
-1803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+3837
-1803
lines changed

.bzrfileids

953 Bytes
Binary file not shown.

BUILD/build_mccge.sh

Lines changed: 467 additions & 156 deletions
Large diffs are not rendered by default.

BUILD/check-cpu

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ check_cpu () {
1616
# on Linux (and others?) we can get detailed CPU information out of /proc
1717
cpuinfo="cat $CPUINFO"
1818

19+
# detect CPU architecture
20+
cpu_arch=`$cpuinfo | grep 'arch' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
21+
1922
# detect CPU family
2023
cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
2124
if test -z "$cpu_family" ; then
2225
cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
2326
fi
24-
2527
# detect CPU vendor and model
2628
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
2729
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
@@ -56,18 +58,19 @@ check_cpu () {
5658
fi
5759
;;
5860
*)
59-
cpu_family=`uname -m`;
60-
model_name=`uname -p`;
61+
cpu_family=`uname -p`;
62+
model_name=`uname -m`;
6163
;;
6264
esac
6365
fi
6466

6567
# detect CPU shortname as used by gcc options
6668
# this list is not complete, feel free to add further entries
6769
cpu_arg=""
68-
case "$cpu_family--$model_name" in
70+
low_cpu_arg=""
71+
case "$cpu_vendor--$cpu_family--$model_name--$cpu_arch" in
6972
# DEC Alpha
70-
Alpha*EV6*)
73+
*Alpha*EV6*)
7174
cpu_arg="ev6";
7275
;;
7376
#Core 2 Duo
@@ -96,6 +99,13 @@ check_cpu () {
9699
*Pentium*4*Mobile*)
97100
cpu_arg="pentium4m"
98101
;;
102+
*Pentium\(R\)*\ M*)
103+
cpu_arg="pentium-m"
104+
low_cpu_arg="pentium3"
105+
;;
106+
*Pentium\(R\)*\ D*)
107+
cpu_arg="prescott"
108+
;;
99109
*Pentium*4*)
100110
cpu_arg="pentium4"
101111
;;
@@ -120,6 +130,12 @@ check_cpu () {
120130
*Celeron*)
121131
cpu_arg="pentium2"
122132
;;
133+
*Atom*)
134+
cpu_arg="prescott"
135+
;;
136+
*GenuineIntel*)
137+
cpu_arg="pentium"
138+
;;
123139
*Turion*)
124140
cpu_arg="athlon64"
125141
;;
@@ -129,9 +145,30 @@ check_cpu () {
129145
*Athlon*)
130146
cpu_arg="athlon"
131147
;;
148+
*AMD-K7*)
149+
cpu_arg="athlon"
150+
;;
151+
*Athlon*XP\ *)
152+
cpu_arg="athlon-xp"
153+
;;
154+
*AMD*Sempron\(tm\)*)
155+
cpu_arg="athlon-mp"
156+
;;
157+
*AMD*Athlon\(tm\)\ 64*)
158+
cpu_arg="k8"
159+
;;
132160
*Opteron*)
133161
cpu_arg="opteron"
134162
;;
163+
*Phenom*)
164+
cpu_arg="k8"
165+
;;
166+
*AuthenticAMD*)
167+
cpu_arg="k6"
168+
;;
169+
*VIA\ *)
170+
cpu_arg="i686"
171+
;;
135172
# MacOSX / Intel
136173
*i386*i486*)
137174
cpu_arg="pentium-m"
@@ -143,8 +180,11 @@ check_cpu () {
143180
*Itanium*)
144181
cpu_arg="itanium"
145182
;;
183+
*IA-64*)
184+
cpu_arg="itanium"
185+
;;
146186
# Solaris Sparc
147-
*sparc*sun4u*)
187+
*sparc*sun4[uv]*)
148188
cpu_arg="sparc"
149189
;;
150190
# Power PC
@@ -160,6 +200,10 @@ check_cpu () {
160200
;;
161201
esac
162202

203+
if test "x$low_cpu_arg" = "x" ; then
204+
low_cpu_arg="$cpu_arg"
205+
fi
206+
163207
if test -z "$cpu_arg" ; then
164208
if test "$CPUINFO" != " " ; then
165209
# fallback to uname if necessary
@@ -198,7 +242,7 @@ check_cpu () {
198242
case `gcc -dumpmachine` in
199243
i?86-* | x86_64-*)
200244
if test "$cc_comp" -lt 304 ; then
201-
check_cpu_cflags="-mcpu=${cpu_arg}"
245+
check_cpu_cflags="-mcpu=${low_cpu_arg}"
202246
elif test "$cc_comp" -ge 402 ; then
203247
check_cpu_cflags="-mtune=native"
204248
else

client/mysqltest.cc

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static my_bool parsing_disabled= 0;
103103
static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
104104
display_metadata= FALSE, display_result_sorted= FALSE;
105105
static my_bool disable_query_log= 0, disable_result_log= 0;
106+
static my_bool disable_connect_log= 1;
106107
static my_bool disable_warnings= 0;
107108
static my_bool disable_info= 1;
108109
static my_bool abort_on_error= 1;
@@ -242,7 +243,9 @@ struct st_connection
242243
int cur_query_len;
243244
pthread_mutex_t mutex;
244245
pthread_cond_t cond;
246+
pthread_t tid;
245247
int query_done;
248+
my_bool has_thread;
246249
#endif /*EMBEDDED_LIBRARY*/
247250
};
248251

@@ -273,6 +276,7 @@ enum enum_commands {
273276
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
274277
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
275278
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
279+
Q_ENABLE_CONNECT_LOG, Q_DISABLE_CONNECT_LOG,
276280
Q_WAIT_FOR_SLAVE_TO_STOP,
277281
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
278282
Q_ENABLE_INFO, Q_DISABLE_INFO,
@@ -340,6 +344,8 @@ const char *command_names[]=
340344
/* Enable/disable that the _result_ from a query is logged to result file */
341345
"enable_result_log",
342346
"disable_result_log",
347+
"enable_connect_log",
348+
"disable_connect_log",
343349
"wait_for_slave_to_stop",
344350
"enable_warnings",
345351
"disable_warnings",
@@ -733,8 +739,6 @@ pthread_handler_t send_one_query(void *arg)
733739
static int do_send_query(struct st_connection *cn, const char *q, int q_len,
734740
int flags)
735741
{
736-
pthread_t tid;
737-
738742
if (flags & QUERY_REAP_FLAG)
739743
return mysql_send_query(&cn->mysql, q, q_len);
740744

@@ -745,9 +749,10 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
745749
cn->cur_query= q;
746750
cn->cur_query_len= q_len;
747751
cn->query_done= 0;
748-
if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
752+
if (pthread_create(&cn->tid, &cn_thd_attrib, send_one_query, (void*)cn))
749753
die("Cannot start new thread for query");
750754

755+
cn->has_thread= TRUE;
751756
return 0;
752757
}
753758

@@ -760,6 +765,14 @@ static void wait_query_thread_end(struct st_connection *con)
760765
pthread_cond_wait(&con->cond, &con->mutex);
761766
pthread_mutex_unlock(&con->mutex);
762767
}
768+
if (con->has_thread)
769+
{
770+
#ifndef __WIN__
771+
/* May hang on Windows, but the problem it solves is not seen there */
772+
pthread_join(con->tid, NULL);
773+
#endif
774+
con->has_thread= FALSE;
775+
}
763776
}
764777

765778
#else /*EMBEDDED_LIBRARY*/
@@ -2175,8 +2188,14 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
21752188
DBUG_ENTER("var_query_set");
21762189
LINT_INIT(res);
21772190

2191+
/* Only white space or ) allowed past ending ` */
21782192
while (end > query && *end != '`')
2193+
{
2194+
if (*end && (*end != ' ' && *end != '\t' && *end != '\n' && *end != ')'))
2195+
die("Spurious text after `query` expression");
21792196
--end;
2197+
}
2198+
21802199
if (query == end)
21812200
die("Syntax error in query, missing '`'");
21822201
++query;
@@ -3834,7 +3853,18 @@ void do_perl(struct st_command *command)
38343853
if (!error)
38353854
my_delete(temp_file_path, MYF(0));
38363855

3837-
handle_command_error(command, WEXITSTATUS(error));
3856+
/* Check for error code that indicates perl could not be started */
3857+
int exstat= WEXITSTATUS(error);
3858+
#ifdef __WIN__
3859+
if (exstat == 1)
3860+
/* Text must begin 'perl not found' as mtr looks for it */
3861+
abort_not_supported_test("perl not found in path or did not start");
3862+
#else
3863+
if (exstat == 127)
3864+
abort_not_supported_test("perl not found in path");
3865+
#endif
3866+
else
3867+
handle_command_error(command, exstat);
38383868
}
38393869
dynstr_free(&ds_delimiter);
38403870
DBUG_VOID_RETURN;
@@ -4778,6 +4808,16 @@ void select_connection_name(const char *name)
47784808

47794809
set_current_connection(con);
47804810

4811+
/* Connection logging if enabled */
4812+
if (!disable_connect_log && !disable_query_log)
4813+
{
4814+
DYNAMIC_STRING *ds= &ds_res;
4815+
4816+
dynstr_append_mem(ds, "connection ", 11);
4817+
replace_dynstr_append(ds, name);
4818+
dynstr_append_mem(ds, ";\n", 2);
4819+
}
4820+
47814821
DBUG_VOID_RETURN;
47824822
}
47834823

@@ -4865,6 +4905,16 @@ void do_close_connection(struct st_command *command)
48654905
var_set_string("$CURRENT_CONNECTION", con->name);
48664906
}
48674907

4908+
/* Connection logging if enabled */
4909+
if (!disable_connect_log && !disable_query_log)
4910+
{
4911+
DYNAMIC_STRING *ds= &ds_res;
4912+
4913+
dynstr_append_mem(ds, "disconnect ", 11);
4914+
replace_dynstr_append(ds, ds_connection.str);
4915+
dynstr_append_mem(ds, ";\n", 2);
4916+
}
4917+
48684918
DBUG_VOID_RETURN;
48694919
}
48704920

@@ -4999,6 +5049,13 @@ int connect_n_handle_errors(struct st_command *command,
49995049
dynstr_append_mem(ds, delimiter, delimiter_length);
50005050
dynstr_append_mem(ds, "\n", 1);
50015051
}
5052+
/* Simlified logging if enabled */
5053+
if (!disable_connect_log && !disable_query_log)
5054+
{
5055+
replace_dynstr_append(ds, command->query);
5056+
dynstr_append_mem(ds, ";\n", 2);
5057+
}
5058+
50025059
while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
50035060
CLIENT_MULTI_STATEMENTS))
50045061
{
@@ -5187,6 +5244,7 @@ void do_connect(struct st_command *command)
51875244

51885245
#ifdef EMBEDDED_LIBRARY
51895246
con_slot->query_done= 1;
5247+
con_slot->has_thread= FALSE;
51905248
#endif
51915249
if (!mysql_init(&con_slot->mysql))
51925250
die("Failed on mysql_init()");
@@ -5507,6 +5565,8 @@ int read_line(char *buf, int size)
55075565
char c, UNINIT_VAR(last_quote);
55085566
char *p= buf, *buf_end= buf + size - 1;
55095567
int skip_char= 0;
5568+
my_bool have_slash= FALSE;
5569+
55105570
enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
55115571
R_COMMENT, R_LINE_START} state= R_LINE_START;
55125572
DBUG_ENTER("read_line");
@@ -5578,9 +5638,13 @@ int read_line(char *buf, int size)
55785638
}
55795639
else if (c == '\'' || c == '"' || c == '`')
55805640
{
5581-
last_quote= c;
5582-
state= R_Q;
5641+
if (! have_slash)
5642+
{
5643+
last_quote= c;
5644+
state= R_Q;
5645+
}
55835646
}
5647+
have_slash= (c == '\\');
55845648
break;
55855649

55865650
case R_COMMENT:
@@ -7301,11 +7365,13 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
73017365
(flags & QUERY_REAP_FLAG));
73027366
DBUG_ENTER("run_query");
73037367

7304-
init_dynamic_string(&ds_warnings, NULL, 0, 256);
7305-
73067368
if (cn->pending && (flags & QUERY_SEND_FLAG))
73077369
die ("Cannot run query on connection between send and reap");
73087370

7371+
if (!(flags & QUERY_SEND_FLAG) && !cn->pending)
7372+
die ("Cannot reap on a connection without pending send");
7373+
7374+
init_dynamic_string(&ds_warnings, NULL, 0, 256);
73097375
/*
73107376
Evaluate query if this is an eval command
73117377
*/
@@ -8046,6 +8112,8 @@ int main(int argc, char **argv)
80468112
case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
80478113
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
80488114
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
8115+
case Q_ENABLE_CONNECT_LOG: disable_connect_log=0; break;
8116+
case Q_DISABLE_CONNECT_LOG: disable_connect_log=1; break;
80498117
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
80508118
case Q_DISABLE_WARNINGS: disable_warnings=1; break;
80518119
case Q_ENABLE_INFO: disable_info=0; break;

config/ac-macros/maintainer.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AC_DEFUN([MY_MAINTAINER_MODE], [
1616
AC_DEFUN([MY_MAINTAINER_MODE_WARNINGS], [
1717
# Setup GCC warning options.
1818
AS_IF([test "$GCC" = "yes"], [
19-
C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Werror"
19+
C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror"
2020
CXX_WARNINGS="${C_WARNINGS} -Wno-unused-parameter"
2121
])
2222

dbug/dbug.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,8 @@ static void DbugParse(CODE_STATE *cs, const char *control)
455455
rel= control[0] == '+' || control[0] == '-';
456456
if ((!rel || (!stack->out_file && !stack->next)))
457457
{
458-
/*
459-
We need to free what's already in init_settings, because unlike
460-
the thread related stack frames there's a chance that something
461-
is in these variables already.
462-
*/
463-
if (stack == &init_settings)
464-
FreeState(cs, stack, 0);
458+
/* Free memory associated with the state before resetting its members */
459+
FreeState(cs, stack, 0);
465460
stack->flags= 0;
466461
stack->delay= 0;
467462
stack->maxdepth= 0;
@@ -1447,8 +1442,8 @@ static void PushState(CODE_STATE *cs)
14471442
struct settings *new_malloc;
14481443

14491444
new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings));
1445+
bzero(new_malloc, sizeof(struct settings));
14501446
new_malloc->next= cs->stack;
1451-
new_malloc->out_file= NULL;
14521447
cs->stack= new_malloc;
14531448
}
14541449

@@ -1957,7 +1952,7 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name)
19571952

19581953
static void DBUGCloseFile(CODE_STATE *cs, FILE *fp)
19591954
{
1960-
if (fp != stderr && fp != stdout && fclose(fp) == EOF)
1955+
if (fp != NULL && fp != stderr && fp != stdout && fclose(fp) == EOF)
19611956
{
19621957
pthread_mutex_lock(&THR_LOCK_dbug);
19631958
(void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process);

include/mysql.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ struct st_mysql_options {
224224

225225
enum mysql_status
226226
{
227-
MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
227+
MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
228+
MYSQL_STATUS_STATEMENT_GET_RESULT
228229
};
229230

230231
enum mysql_protocol_type

0 commit comments

Comments
 (0)