summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorunknown <sanja@askmonty.org>2010-02-01 08:14:12 +0200
committerunknown <sanja@askmonty.org>2010-02-01 08:14:12 +0200
commite5099a2c85468d01d084b1071f724bc20766271d (patch)
tree50e180dfcaa058cefb382d2ab931592cddbd007d /extra
parentf83113df07d6ef8e8a6d1db8f6dc3bb90fb0652a (diff)
parente9bce6c9d4bde35306b845e22e9b5ada69c4512f (diff)
downloadmariadb-git-e5099a2c85468d01d084b1071f724bc20766271d.tar.gz
merge 5.1->5.2
Diffstat (limited to 'extra')
-rw-r--r--extra/comp_err.c12
-rw-r--r--extra/libevent/devpoll.c2
-rw-r--r--extra/libevent/evbuffer.c4
-rw-r--r--extra/yassl/src/yassl_error.cpp2
-rw-r--r--extra/yassl/taocrypt/include/asn.hpp1
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp115
6 files changed, 78 insertions, 58 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c
index e36e85f6f0c..9326444ade9 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -660,7 +660,7 @@ static ha_checksum checksum_format_specifier(const char* msg)
case 'u':
case 'x':
case 's':
- chksum= my_checksum(chksum, start, (uint) (p - start));
+ chksum= my_checksum(chksum, start, (uint) (p + 1 - start));
start= 0; /* Not in format specifier anymore */
break;
@@ -1030,8 +1030,10 @@ static char *parse_text_line(char *pos)
{
int i, nr;
char *row= pos;
+ size_t len;
DBUG_ENTER("parse_text_line");
+ len= strlen (pos);
while (*pos)
{
if (*pos == '\\')
@@ -1039,11 +1041,11 @@ static char *parse_text_line(char *pos)
switch (*++pos) {
case '\\':
case '"':
- VOID(strmov(pos - 1, pos));
+ VOID(memmove (pos - 1, pos, len - (row - pos)));
break;
case 'n':
pos[-1]= '\n';
- VOID(strmov(pos, pos + 1));
+ VOID(memmove (pos, pos + 1, len - (row - pos)));
break;
default:
if (*pos >= '0' && *pos < '8')
@@ -1053,10 +1055,10 @@ static char *parse_text_line(char *pos)
nr= nr * 8 + (*(pos++) - '0');
pos -= i;
pos[-1]= nr;
- VOID(strmov(pos, pos + i));
+ VOID(memmove (pos, pos + i, len - (row - pos)));
}
else if (*pos)
- VOID(strmov(pos - 1, pos)); /* Remove '\' */
+ VOID(memmove (pos - 1, pos, len - (row - pos))); /* Remove '\' */
}
}
else
diff --git a/extra/libevent/devpoll.c b/extra/libevent/devpoll.c
index 20813380b20..82427c9e229 100644
--- a/extra/libevent/devpoll.c
+++ b/extra/libevent/devpoll.c
@@ -140,7 +140,7 @@ devpoll_init(struct event_base *base)
return (NULL);
if (getrlimit(RLIMIT_NOFILE, &rl) == 0 &&
- rl.rlim_cur != RLIM_INFINITY)
+ (unsigned long long) rl.rlim_cur != (unsigned long long) RLIM_INFINITY)
nfiles = rl.rlim_cur - 1;
/* Initialize the kernel queue */
diff --git a/extra/libevent/evbuffer.c b/extra/libevent/evbuffer.c
index 33315120c3e..758143c8225 100644
--- a/extra/libevent/evbuffer.c
+++ b/extra/libevent/evbuffer.c
@@ -25,12 +25,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <sys/types.h>
+
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp
index a1ef8578da6..2c4d6c47c78 100644
--- a/extra/yassl/src/yassl_error.cpp
+++ b/extra/yassl/src/yassl_error.cpp
@@ -60,7 +60,7 @@ void SetErrorString(YasslError error, char* buffer)
using namespace TaoCrypt;
const int max = MAX_ERROR_SZ; // shorthand
- switch (error) {
+ switch ((int) error) {
// yaSSL proper errors
case range_error :
diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp
index 1c1850cb47e..168b8a8c755 100644
--- a/extra/yassl/taocrypt/include/asn.hpp
+++ b/extra/yassl/taocrypt/include/asn.hpp
@@ -305,6 +305,7 @@ private:
bool ValidateSignature(SignerList*);
bool ConfirmSignature(Source&);
void GetKey();
+ char* AddTag(char*, const char*, const char*, word32, word32);
void GetName(NameType);
void GetValidity();
void GetDate(DateType);
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index 78200841bda..f44d550e95b 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -652,6 +652,25 @@ word32 CertDecoder::GetDigest()
}
+// memory length checked add tag to buffer
+char* CertDecoder::AddTag(char* ptr, const char* buf_end, const char* tag_name,
+ word32 tag_name_length, word32 tag_value_length)
+{
+ if (ptr + tag_name_length + tag_value_length > buf_end) {
+ source_.SetError(CONTENT_E);
+ return 0;
+ }
+
+ memcpy(ptr, tag_name, tag_name_length);
+ ptr += tag_name_length;
+
+ memcpy(ptr, source_.get_current(), tag_value_length);
+ ptr += tag_value_length;
+
+ return ptr;
+}
+
+
// process NAME, either issuer or subject
void CertDecoder::GetName(NameType nt)
{
@@ -659,11 +678,22 @@ void CertDecoder::GetName(NameType nt)
SHA sha;
word32 length = GetSequence(); // length of all distinguished names
- assert (length < ASN_NAME_MAX);
+
+ if (length >= ASN_NAME_MAX)
+ return;
length += source_.get_index();
- char* ptr = (nt == ISSUER) ? issuer_ : subject_;
- word32 idx = 0;
+ char* ptr;
+ char* buf_end;
+
+ if (nt == ISSUER) {
+ ptr = issuer_;
+ buf_end = ptr + sizeof(issuer_) - 1; // 1 byte for trailing 0
+ }
+ else {
+ ptr = subject_;
+ buf_end = ptr + sizeof(subject_) - 1; // 1 byte for trailing 0
+ }
while (source_.get_index() < length) {
GetSet();
@@ -685,47 +715,36 @@ void CertDecoder::GetName(NameType nt)
byte id = source_.next();
b = source_.next(); // strType
word32 strLen = GetLength(source_);
- bool copy = false;
-
- if (id == COMMON_NAME) {
- memcpy(&ptr[idx], "/CN=", 4);
- idx += 4;
- copy = true;
- }
- else if (id == SUR_NAME) {
- memcpy(&ptr[idx], "/SN=", 4);
- idx += 4;
- copy = true;
- }
- else if (id == COUNTRY_NAME) {
- memcpy(&ptr[idx], "/C=", 3);
- idx += 3;
- copy = true;
- }
- else if (id == LOCALITY_NAME) {
- memcpy(&ptr[idx], "/L=", 3);
- idx += 3;
- copy = true;
- }
- else if (id == STATE_NAME) {
- memcpy(&ptr[idx], "/ST=", 4);
- idx += 4;
- copy = true;
- }
- else if (id == ORG_NAME) {
- memcpy(&ptr[idx], "/O=", 3);
- idx += 3;
- copy = true;
- }
- else if (id == ORGUNIT_NAME) {
- memcpy(&ptr[idx], "/OU=", 4);
- idx += 4;
- copy = true;
- }
- if (copy) {
- memcpy(&ptr[idx], source_.get_current(), strLen);
- idx += strLen;
+ switch (id) {
+ case COMMON_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/CN=", 4, strLen)))
+ return;
+ break;
+ case SUR_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/SN=", 4, strLen)))
+ return;
+ break;
+ case COUNTRY_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/C=", 3, strLen)))
+ return;
+ break;
+ case LOCALITY_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/L=", 3, strLen)))
+ return;
+ break;
+ case STATE_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/ST=", 4, strLen)))
+ return;
+ break;
+ case ORG_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/O=", 3, strLen)))
+ return;
+ break;
+ case ORGUNIT_NAME:
+ if (!(ptr = AddTag(ptr, buf_end, "/OU=", 4, strLen)))
+ return;
+ break;
}
sha.Update(source_.get_current(), strLen);
@@ -740,17 +759,15 @@ void CertDecoder::GetName(NameType nt)
word32 length = GetLength(source_);
if (email) {
- memcpy(&ptr[idx], "/emailAddress=", 14);
- idx += 14;
-
- memcpy(&ptr[idx], source_.get_current(), length);
- idx += length;
+ if (!(ptr = AddTag(ptr, buf_end, "/emailAddress=", 14, length)))
+ return;
}
source_.advance(length);
}
}
- ptr[idx++] = 0;
+
+ *ptr = 0;
if (nt == ISSUER)
sha.Final(issuerHash_);