← Back to team overview

maria-developers team mailing list archive

Re: c5238d7b3b7: MDEV-22545: my_vsnprintf behaves not as in C standard

 

Hi, Oleksandr!

On May 20, Oleksandr Byelkin wrote:
> revision-id: c5238d7b3b7 (mariadb-10.5.3-200-gc5238d7b3b7)
> parent(s): 8f9c53586bf
> author: Oleksandr Byelkin <sanja@xxxxxxxxxxx>
> committer: Oleksandr Byelkin <sanja@xxxxxxxxxxx>
> timestamp: 2020-05-20 08:35:12 +0200
> message:
> 
> MDEV-22545: my_vsnprintf behaves not as in C standard
> 
> Added parameter %T for string which should be visibly truncated.
> 
> diff --git a/include/mysql/service_my_snprintf.h b/include/mysql/service_my_snprintf.h
> index bd1f069c527..94a9e07dcbb 100644
> --- a/include/mysql/service_my_snprintf.h
> +++ b/include/mysql/service_my_snprintf.h
> @@ -69,6 +70,9 @@
>    Format 'M': takes one integer, prints this integer, space, double quote
>    error message, double quote. In other words
>      printf("%M", n) === printf("%d \"%s\"", n, strerror(n))
> +
> +  Format 'T': takes string and print it like s but if the strints shoud be

should

> +  truncated puts "..." at the end.
>  */
>  
>  #ifdef __cplusplus
> diff --git a/mysql-test/main/frm-debug.result b/mysql-test/main/frm-debug.result
> index caf344e241d..332d7e00a8f 100644
> --- a/mysql-test/main/frm-debug.result
> +++ b/mysql-test/main/frm-debug.result
> @@ -13,8 +13,8 @@ CREATE TABLE t1 (c01 INT, c02 CHAR(20), c03 TEXT, c04 DOUBLE);
>  Warnings:
>  Note	1105	build_frm_image: Field data type info length: 14
>  Note	1105	DBUG: [0] name='c01' type_info=''
> -Note	1105	DBUG: [1] name='c02' type_info='xc...'
> -Note	1105	DBUG: [2] name='c03' type_info='xb...'
> +Note	1105	DBUG: [1] name='c02' type_info='xchar'
> +Note	1105	DBUG: [2] name='c03' type_info='xblob'

good

>  Note	1105	DBUG: [3] name='c04' type_info=''
>  SET SESSION debug_dbug="-d,frm_data_type_info_emulate";
>  SET SESSION debug_dbug="-d,frm_data_type_info";
> diff --git a/mysql-test/main/xml.result b/mysql-test/main/xml.result
> index efaca961b4a..84dbd68438f 100644
> --- a/mysql-test/main/xml.result
> +++ b/mysql-test/main/xml.result
> @@ -1007,7 +1007,7 @@ Warning	1292	Truncated incorrect INTEGER value: 'string          '
>  Warning	1292	Truncated incorrect INTEGER value: 'string          '
>  DROP PROCEDURE spxml;
>  select UpdateXML('<a>a</a>',repeat('a b ',1000),'');
> -ERROR HY000: XPATH syntax error: 'b a b a b a b a b a b a b a b...'
> +ERROR HY000: XPATH syntax error: 'b a b a b a b a b a b a b a b a '

this doesn't look right, the string is truncated, isn't it?

>  select ExtractValue('<a>a</a>', '/a[@x=@y0123456789_0123456789_0123456789_0123456789]');
>  ERROR HY000: XPATH error: comparison of two nodesets is not supported: '=@y0123456789_0123456789_0123...'
>  select ExtractValue('<a>a</a>', '/a[@x=$y0123456789_0123456789_0123456789_0123456789]');
> @@ -1110,9 +1110,9 @@ NULL
>  # Bug#57279 updatexml dies with: Assertion failed: str_arg[length] == 0
>  #
>  SELECT UPDATEXML(NULL, (LPAD(0.1111E-15, '2011', 1)), 1);
> -ERROR 22007: Illegal double '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...' value found during parsing
> +ERROR 22007: Illegal double '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' value found during parsing

same here, lpad appends 2011 characters, so this "double" is clearly
truncated.

Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx