Skip to content

Commit 6c15f67

Browse files
author
Davi Arnaut
committed
Merge of mysql-5.1-bugteam into mysql-trunk-merge.
2 parents 8d407c5 + c96b249 commit 6c15f67

34 files changed

Lines changed: 147 additions & 172 deletions

client/mysql.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,7 +3656,7 @@ xmlencode_print(const char *src, uint length)
36563656
tee_fputs("NULL", PAGER);
36573657
else
36583658
{
3659-
for (const char *p = src; length; *p++, length--)
3659+
for (const char *p = src; length; p++, length--)
36603660
{
36613661
const char *t;
36623662
if ((t = array_value(xmlmeta, *p)))
@@ -4744,7 +4744,7 @@ static const char* construct_prompt()
47444744
struct tm *t = localtime(&lclock);
47454745

47464746
/* parse thru the settings for the prompt */
4747-
for (char *c = current_prompt; *c ; *c++)
4747+
for (char *c = current_prompt; *c ; c++)
47484748
{
47494749
if (*c != PROMPT_CHAR)
47504750
processed_prompt.append(*c);

client/mysql_upgrade.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ static int upgrade_already_done(void)
596596

597597
my_fclose(in, MYF(0));
598598

599-
return (strncmp(buf, MYSQL_SERVER_VERSION,
599+
if (!res)
600+
return 0; /* Could not read from file => not sure */
601+
602+
return (strncmp(res, MYSQL_SERVER_VERSION,
600603
sizeof(MYSQL_SERVER_VERSION)-1)==0);
601604
}
602605

extra/comp_err.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ static struct message *parse_message_string(struct message *new_message,
857857
static struct errors *parse_error_string(char *str, int er_count)
858858
{
859859
struct errors *new_error;
860-
char *start;
861860
DBUG_ENTER("parse_error_string");
862861
DBUG_PRINT("enter", ("str: %s", str));
863862

@@ -868,7 +867,6 @@ static struct errors *parse_error_string(char *str, int er_count)
868867
DBUG_RETURN(0); /* OOM: Fatal error */
869868

870869
/* getting the error name */
871-
start= str;
872870
str= skip_delimiters(str);
873871

874872
if (!(new_error->er_name= get_word(&str)))

extra/yassl/src/yassl_imp.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -884,21 +884,19 @@ void Alert::Process(input_buffer& input, SSL& ssl)
884884
else
885885
hmac(ssl, verify, data, aSz, alert, true);
886886

887-
// read mac and fill
887+
// read mac and skip fill
888888
int digestSz = ssl.getCrypto().get_digest().get_digestSize();
889889
opaque mac[SHA_LEN];
890890
input.read(mac, digestSz);
891891

892892
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
893893
int ivExtra = 0;
894-
opaque fill;
895894

896895
if (ssl.isTLSv1_1())
897896
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
898897
int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
899898
aSz - digestSz;
900-
for (int i = 0; i < padSz; i++)
901-
fill = input[AUTO];
899+
input.set_current(input.get_current() + padSz);
902900
}
903901

904902
// verify
@@ -981,17 +979,17 @@ output_buffer& operator<<(output_buffer& output, const Data& data)
981979
void Data::Process(input_buffer& input, SSL& ssl)
982980
{
983981
int msgSz = ssl.getSecurity().get_parms().encrypt_size_;
984-
int pad = 0, padByte = 0;
982+
int pad = 0, padSz = 0;
985983
int ivExtra = 0;
986984

987985
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
988986
if (ssl.isTLSv1_1()) // IV
989987
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
990988
pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1);
991-
padByte = 1;
989+
padSz = 1;
992990
}
993991
int digestSz = ssl.getCrypto().get_digest().get_digestSize();
994-
int dataSz = msgSz - ivExtra - digestSz - pad - padByte;
992+
int dataSz = msgSz - ivExtra - digestSz - pad - padSz;
995993
opaque verify[SHA_LEN];
996994

997995
const byte* rawData = input.get_buffer() + input.get_current();
@@ -1020,14 +1018,10 @@ void Data::Process(input_buffer& input, SSL& ssl)
10201018
hmac(ssl, verify, rawData, dataSz, application_data, true);
10211019
}
10221020

1023-
// read mac and fill
1021+
// read mac and skip fill
10241022
opaque mac[SHA_LEN];
1025-
opaque fill;
10261023
input.read(mac, digestSz);
1027-
for (int i = 0; i < pad; i++)
1028-
fill = input[AUTO];
1029-
if (padByte)
1030-
fill = input[AUTO];
1024+
input.set_current(input.get_current() + pad + padSz);
10311025

10321026
// verify
10331027
if (dataSz) {
@@ -2073,11 +2067,9 @@ void Finished::Process(input_buffer& input, SSL& ssl)
20732067
if (ssl.isTLSv1_1())
20742068
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
20752069

2076-
opaque fill;
20772070
int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
20782071
HANDSHAKE_HEADER - finishedSz - digestSz;
2079-
for (int i = 0; i < padSz; i++)
2080-
fill = input[AUTO];
2072+
input.set_current(input.get_current() + padSz);
20812073

20822074
// verify mac
20832075
if (memcmp(mac, verifyMAC, digestSz)) {

include/my_pthread.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,13 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
255255
we want to make sure that no such flags are set.
256256
*/
257257
#if defined(HAVE_SIGACTION) && !defined(my_sigset)
258-
#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \
258+
#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; \
259259
DBUG_ASSERT((A) != 0); \
260260
sigemptyset(&l_set); \
261261
l_s.sa_handler = (B); \
262262
l_s.sa_mask = l_set; \
263263
l_s.sa_flags = 0; \
264-
l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\
265-
DBUG_ASSERT(l_rc == 0); \
264+
sigaction((A), &l_s, NULL); \
266265
} while (0)
267266
#elif defined(HAVE_SIGSET) && !defined(my_sigset)
268267
#define my_sigset(A,B) sigset((A),(B))

include/mysys_err.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ extern const char *globerrs[]; /* my_error_messages is here */
6363
#define EE_UNKNOWN_COLLATION 28
6464
#define EE_FILENOTFOUND 29
6565
#define EE_FILE_NOT_CLOSED 30
66-
#define EE_ERROR_LAST 30 /* Copy last error nr */
66+
#define EE_CHANGE_OWNERSHIP 31
67+
#define EE_CHANGE_PERMISSIONS 32
68+
#define EE_ERROR_LAST 32 /* Copy last error nr */
6769
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */
6870

6971
/* exit codes for all MySQL programs */

mysys/errors.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const char *globerrs[GLOBERRS]=
4949
"Can't sync file '%s' to disk (Errcode: %d)",
5050
"Collation '%s' is not a compiled collation and is not specified in the '%s' file",
5151
"File '%s' not found (Errcode: %d)",
52-
"File '%s' (fileno: %d) was not closed"
52+
"File '%s' (fileno: %d) was not closed",
53+
"Can't change ownership of the file '%s' (Errcode: %d)",
54+
"Can't change permissions of the file '%s' (Errcode: %d)",
5355
};
5456

5557
void init_glob_errs(void)
@@ -90,6 +92,8 @@ void init_glob_errs()
9092
EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file";
9193
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)";
9294
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
95+
EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)";
96+
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)";
9397
}
9498
#endif
9599

mysys/mf_iocache.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,16 +1703,19 @@ int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count,
17031703
#endif
17041704

17051705

1706-
int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
1706+
int my_b_flush_io_cache(IO_CACHE *info,
1707+
int need_append_buffer_lock __attribute__((unused)))
17071708
{
17081709
size_t length;
1709-
my_bool append_cache;
17101710
my_off_t pos_in_file;
1711+
my_bool append_cache= (info->type == SEQ_READ_APPEND);
17111712
DBUG_ENTER("my_b_flush_io_cache");
17121713
DBUG_PRINT("enter", ("cache: 0x%lx", (long) info));
17131714

1714-
if (!(append_cache = (info->type == SEQ_READ_APPEND)))
1715-
need_append_buffer_lock=0;
1715+
#ifdef THREAD
1716+
if (!append_cache)
1717+
need_append_buffer_lock= 0;
1718+
#endif
17161719

17171720
if (info->type == WRITE_CACHE || append_cache)
17181721
{

mysys/my_copy.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "mysys_priv.h"
1717
#include <my_dir.h> /* for stat */
1818
#include <m_string.h>
19+
#include "mysys_err.h"
1920
#if defined(HAVE_UTIME_H)
2021
#include <utime.h>
2122
#elif defined(HAVE_SYS_UTIME_H)
@@ -56,7 +57,6 @@ int my_copy(const char *from, const char *to, myf MyFlags)
5657
File from_file,to_file;
5758
uchar buff[IO_SIZE];
5859
MY_STAT stat_buff,new_stat_buff;
59-
int res;
6060
DBUG_ENTER("my_copy");
6161
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
6262

@@ -102,9 +102,23 @@ int my_copy(const char *from, const char *to, myf MyFlags)
102102

103103
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
104104
DBUG_RETURN(0); /* File copyed but not stat */
105-
res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */
105+
/* Copy modes */
106+
if (chmod(to, stat_buff.st_mode & 07777))
107+
{
108+
my_errno= errno;
109+
if (MyFlags & (MY_FAE+MY_WME))
110+
my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
111+
goto err;
112+
}
106113
#if !defined(__WIN__)
107-
res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */
114+
/* Copy ownership */
115+
if (chown(to, stat_buff.st_uid, stat_buff.st_gid))
116+
{
117+
my_errno= errno;
118+
if (MyFlags & (MY_FAE+MY_WME))
119+
my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
120+
goto err;
121+
}
108122
#endif
109123

110124
if (MyFlags & MY_COPYTIME)

mysys/my_redel.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
7676
int my_copystat(const char *from, const char *to, int MyFlags)
7777
{
7878
struct stat statbuf;
79-
#if !defined(__WIN__)
80-
int res;
81-
#endif
8279

83-
if (stat((char*) from, &statbuf))
80+
if (stat(from, &statbuf))
8481
{
8582
my_errno=errno;
8683
if (MyFlags & (MY_FAE+MY_WME))
@@ -89,15 +86,30 @@ int my_copystat(const char *from, const char *to, int MyFlags)
8986
}
9087
if ((statbuf.st_mode & S_IFMT) != S_IFREG)
9188
return 1;
92-
(void) chmod(to, statbuf.st_mode & 07777); /* Copy modes */
89+
90+
/* Copy modes */
91+
if (chmod(to, statbuf.st_mode & 07777))
92+
{
93+
my_errno= errno;
94+
if (MyFlags & (MY_FAE+MY_WME))
95+
my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
96+
return -1;
97+
}
9398

9499
#if !defined(__WIN__)
95100
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
96101
{
97102
if (MyFlags & MY_LINK_WARNING)
98103
my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
99104
}
100-
res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */
105+
/* Copy ownership */
106+
if (chown(to, statbuf.st_uid, statbuf.st_gid))
107+
{
108+
my_errno= errno;
109+
if (MyFlags & (MY_FAE+MY_WME))
110+
my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
111+
return -1;
112+
}
101113
#endif /* !__WIN__ */
102114

103115
if (MyFlags & MY_COPYTIME)

0 commit comments

Comments
 (0)