You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
a couple of PS bugs in ps_fetch_bin
1. Do not remove the last character from the blob (indeed, why C/C would corrupt the retrieved value?) 2. Always append a teminating '\0' if fetching into a string, also when nothing was fetched (blob length = 0) this fixes various test failures in --ps-protocol in the server
This commit is contained in:
@@ -936,18 +936,12 @@ void ps_fetch_bin(MYSQL_BIND *r_param,
|
|||||||
{
|
{
|
||||||
copylen= end - current_pos;
|
copylen= end - current_pos;
|
||||||
if (r_param->buffer_length)
|
if (r_param->buffer_length)
|
||||||
{
|
|
||||||
memcpy(r_param->buffer, current_pos, MIN(copylen, r_param->buffer_length));
|
memcpy(r_param->buffer, current_pos, MIN(copylen, r_param->buffer_length));
|
||||||
|
}
|
||||||
if (copylen < r_param->buffer_length &&
|
if (copylen < r_param->buffer_length &&
|
||||||
r_param->buffer_type == MYSQL_TYPE_STRING)
|
r_param->buffer_type == MYSQL_TYPE_STRING)
|
||||||
((char *)r_param->buffer)[copylen]= 0;
|
((char *)r_param->buffer)[copylen]= 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
*r_param->error= copylen > r_param->buffer_length;
|
*r_param->error= copylen > r_param->buffer_length;
|
||||||
/* don't count trailing zero if we fetch into string */
|
|
||||||
if (r_param->buffer_type == MYSQL_TYPE_STRING &&
|
|
||||||
!*r_param->error)
|
|
||||||
field_length--;
|
|
||||||
(*row)+= field_length;
|
(*row)+= field_length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user