Commit 082cfb87 authored by unknown's avatar unknown

BUG#28884 - maybe a problem with malloc into base64.c

Fixed that return value of malloc was not checked.
Fixed wrong argument count (compilation failure) to base64_decode()
function.

Note:
- there is no test case for this fix as this code is never compiled
  into mysql clients/server;
- as this code is used for internal testing purposes only, no changelog
  entry needed.


mysys/base64.c:
  Fixed that return value of malloc was not checked.
  Fixed wrong argument count to base64_decode function.
parent 51cb4ffc
...@@ -256,6 +256,7 @@ main(void) ...@@ -256,6 +256,7 @@ main(void)
char * str; char * str;
char * dst; char * dst;
require(src);
for (j= 0; j<src_len; j++) for (j= 0; j<src_len; j++)
{ {
char c= rand(); char c= rand();
...@@ -265,6 +266,7 @@ main(void) ...@@ -265,6 +266,7 @@ main(void)
/* Encode */ /* Encode */
needed_length= base64_needed_encoded_length(src_len); needed_length= base64_needed_encoded_length(src_len);
str= (char *) malloc(needed_length); str= (char *) malloc(needed_length);
require(str);
for (k= 0; k < needed_length; k++) for (k= 0; k < needed_length; k++)
str[k]= 0xff; /* Fill memory to check correct NUL termination */ str[k]= 0xff; /* Fill memory to check correct NUL termination */
require(base64_encode(src, src_len, str) == 0); require(base64_encode(src, src_len, str) == 0);
...@@ -272,7 +274,8 @@ main(void) ...@@ -272,7 +274,8 @@ main(void)
/* Decode */ /* Decode */
dst= (char *) malloc(base64_needed_decoded_length(strlen(str))); dst= (char *) malloc(base64_needed_decoded_length(strlen(str)));
dst_len= base64_decode(str, strlen(str), dst); require(dst);
dst_len= base64_decode(str, strlen(str), dst, NULL);
require(dst_len == src_len); require(dst_len == src_len);
if (memcmp(src, dst, src_len) != 0) if (memcmp(src, dst, src_len) != 0)
......
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