Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-02 15:05:05+02:00, mats@romeo.(none) +5 -0
BUG#19459 (BINLOG RBR command does not lock tables correctly causing
crash for, e.g., NDB):
Submitting patch to base64_decode() adding extra parameter.
include/base64.h@stripped, 2006-10-02 15:04:54+02:00, mats@romeo.(none) +2 -1
Adding parameter to base64_decode() to return the position just after
the string that was decoded.
mysys/base64.c@stripped, 2006-10-02 15:04:54+02:00, mats@romeo.(none) +46 -17
Adding comment to base64_decode().
Adding parameter to base64_decode() to return the position just after
the string that was decoded.
sql/share/errmsg.txt@stripped, 2006-10-02 15:04:54+02:00, mats@romeo.(none) +3 -0
Adding error message.
storage/ndb/src/mgmapi/mgmapi.cpp@stripped, 2006-10-02 15:04:55+02:00, mats@romeo.(none) +1 -1
Parameters to base64_decode() changed.
unittest/mysys/base64-t.c@stripped, 2006-10-02 15:04:55+02:00, mats@romeo.(none) +1 -1
Parameters to base64_decode() changed.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mats
# Host: romeo.(none)
# Root: /home/bk/b19459-mysql-5.1-new
--- 1.109/sql/share/errmsg.txt 2006-10-02 15:05:33 +02:00
+++ 1.110/sql/share/errmsg.txt 2006-10-02 15:05:33 +02:00
@@ -5837,3 +5837,6 @@
swe "%s kan inte användas i en partitionerad tabell"
ER_RBR_NOT_AVAILABLE
eng "The server was not built with row-based replication"
+ER_BASE64_DECODE_ERROR
+ eng "Decoding of base64 string failed"
+ swe "Avkodning av base64 sträng misslyckades"
--- 1.8/include/base64.h 2006-10-02 15:05:33 +02:00
+++ 1.9/include/base64.h 2006-10-02 15:05:33 +02:00
@@ -39,7 +39,8 @@
/*
Decode a base64 string into data
*/
-int base64_decode(const char *src, size_t src_len, void *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr);
#ifdef __cplusplus
--- 1.12/mysys/base64.c 2006-10-02 15:05:33 +02:00
+++ 1.13/mysys/base64.c 2006-10-02 15:05:33 +02:00
@@ -125,44 +125,69 @@
/*
Decode a base64 string
- Note: We require that dst is pre-allocated to correct size.
- See base64_needed_decoded_length().
+ SYNOPSIS
+ base64_decode()
+ src Pointer to base64-encoded string
+ len Length of string at 'src'
+ dst Pointer to location where decoded data will be stored
+ end_ptr Pointer to variable that will refer to the character
+ after the end of the encoded data that were decoded. Can
+ be NULL.
+
+ DESCRIPTION
+
+ The base64-encoded data in the range ['src','*end_ptr') will be
+ decoded and stored starting at 'dst'. The decoding will stop
+ after 'len' characters have been read from 'src', or when padding
+ occurs in the base64-encoded data. In either case: if 'end_ptr' is
+ non-null, '*end_ptr' will be set to point to the character after
+ the last read character, even in the presence of error.
- RETURN Number of bytes produced in dst or -1 in case of failure
+ NOTE
+ We require that 'dst' is pre-allocated to correct size.
+
+ SEE ALSO
+ base64_needed_decoded_length().
+
+ RETURN VALUE
+ Number of bytes written at 'dst' or -1 in case of failure
*/
int
-base64_decode(const char *src, size_t size, void *dst)
+base64_decode(const char *const src_base, size_t const len,
+ void *dst, const char **end_ptr)
{
char b[3];
size_t i= 0;
char *dst_base= (char *)dst;
+ char const *src= src_base;
char *d= dst_base;
size_t j;
- while (i < size)
+ while (i < len)
{
unsigned c= 0;
size_t mark= 0;
- SKIP_SPACE(src, i, size);
+ SKIP_SPACE(src, i, len);
c += pos(*src++);
c <<= 6;
i++;
- SKIP_SPACE(src, i, size);
+ SKIP_SPACE(src, i, len);
c += pos(*src++);
c <<= 6;
i++;
- SKIP_SPACE(src, i, size);
+ SKIP_SPACE(src, i, len);
- if (* src != '=')
+ if (*src != '=')
c += pos(*src++);
else
{
- i= size;
+ src += 2; /* There should be two bytes padding */
+ i= len;
mark= 2;
c <<= 6;
goto end;
@@ -170,13 +195,14 @@
c <<= 6;
i++;
- SKIP_SPACE(src, i, size);
+ SKIP_SPACE(src, i, len);
if (*src != '=')
c += pos(*src++);
else
{
- i= size;
+ src += 1; /* There should be one byte padding */
+ i= len;
mark= 1;
goto end;
}
@@ -191,11 +217,14 @@
*d++= b[j];
}
- if (i != size)
- {
- return -1;
- }
- return d - dst_base;
+ if (end_ptr != NULL)
+ *end_ptr= src;
+
+ /*
+ The variable 'i' is set to 'len' when padding has been read, so it
+ does not actually reflect the number of bytes read from 'src'.
+ */
+ return i != len ? -1 : d - dst_base;
}
--- 1.64/storage/ndb/src/mgmapi/mgmapi.cpp 2006-10-02 15:05:33 +02:00
+++ 1.65/storage/ndb/src/mgmapi/mgmapi.cpp 2006-10-02 15:05:33 +02:00
@@ -1771,7 +1771,7 @@
break;
void *tmp_data = malloc(base64_needed_decoded_length((size_t) (len - 1)));
- const int res = base64_decode(buf64, len-1, tmp_data);
+ const int res = base64_decode(buf64, len-1, tmp_data, NULL);
delete[] buf64;
UtilBuffer tmp;
tmp.append((void *) tmp_data, res);
--- 1.4/unittest/mysys/base64-t.c 2006-10-02 15:05:34 +02:00
+++ 1.5/unittest/mysys/base64-t.c 2006-10-02 15:05:34 +02:00
@@ -54,7 +54,7 @@
/* Decode */
dst= (char *) malloc(base64_needed_decoded_length(strlen(str)));
- dst_len= base64_decode(str, strlen(str), dst);
+ dst_len= base64_decode(str, strlen(str), dst, NULL);
ok(dst_len == src_len, "Comparing lengths");
cmp= memcmp(src, dst, src_len);
| Thread |
|---|
| • bk commit into 5.1 tree (mats:1.2212) BUG#19459 | Mats Kindahl | 2 Oct |