Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a0f300a6
Commit
a0f300a6
authored
May 12, 2011
by
Tatjana Azundris Nuernberg
Browse files
Options
Browse Files
Download
Plain Diff
auto-merge Bug#11762799/Bug#55436
parents
37f49e69
2683078d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
11 deletions
+42
-11
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+13
-0
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+15
-0
sql/field.cc
sql/field.cc
+3
-3
sql/my_decimal.cc
sql/my_decimal.cc
+6
-5
sql/my_decimal.h
sql/my_decimal.h
+2
-1
strings/decimal.c
strings/decimal.c
+3
-2
No files found.
mysql-test/r/type_newdecimal.result
View file @
a0f300a6
...
...
@@ -1920,4 +1920,17 @@ SELECT SUM(DISTINCT a) FROM t1;
SUM(DISTINCT a)
0.0000
DROP TABLE t1;
#
# Bug#55436: buffer overflow in debug binary of dbug_buff in
# Field_new_decimal::store_value
#
SET SQL_MODE='';
CREATE TABLE t1(f1 DECIMAL(44,24)) ENGINE=MYISAM;
INSERT INTO t1 SET f1 = -64878E-85;
Warnings:
Note 1265 Data truncated for column 'f1' at row 1
SELECT f1 FROM t1;
f1
0.000000000000000000000000
DROP TABLE IF EXISTS t1;
End of 5.1 tests
mysql-test/t/type_newdecimal.test
View file @
a0f300a6
...
...
@@ -1519,4 +1519,19 @@ SELECT AVG(DISTINCT a) FROM t1;
SELECT
SUM
(
DISTINCT
a
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Bug#55436: buffer overflow in debug binary of dbug_buff in
--
echo
# Field_new_decimal::store_value
--
echo
#
# this threw memory warnings on Windows. Also make sure future changes
# don't change these results, as per usual.
SET
SQL_MODE
=
''
;
CREATE
TABLE
t1
(
f1
DECIMAL
(
44
,
24
))
ENGINE
=
MYISAM
;
INSERT
INTO
t1
SET
f1
=
-
64878
E
-
85
;
SELECT
f1
FROM
t1
;
DROP
TABLE
IF
EXISTS
t1
;
--
echo
End
of
5.1
tests
sql/field.cc
View file @
a0f300a6
...
...
@@ -2608,7 +2608,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
DBUG_ENTER
(
"Field_new_decimal::store_value"
);
#ifndef DBUG_OFF
{
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
1
];
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
2
];
DBUG_PRINT
(
"enter"
,
(
"value: %s"
,
dbug_decimal_as_string
(
dbug_buff
,
decimal_value
)));
}
#endif
...
...
@@ -2623,7 +2623,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
}
#ifndef DBUG_OFF
{
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
1
];
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
2
];
DBUG_PRINT
(
"info"
,
(
"saving with precision %d scale: %d value %s"
,
(
int
)
precision
,
(
int
)
dec
,
dbug_decimal_as_string
(
dbug_buff
,
decimal_value
)));
...
...
@@ -2692,7 +2692,7 @@ int Field_new_decimal::store(const char *from, uint length,
}
#ifndef DBUG_OFF
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
1
];
char
dbug_buff
[
DECIMAL_MAX_STR_LENGTH
+
2
];
DBUG_PRINT
(
"enter"
,
(
"value: %s"
,
dbug_decimal_as_string
(
dbug_buff
,
&
decimal_value
)));
#endif
...
...
sql/my_decimal.cc
View file @
a0f300a6
...
...
@@ -99,10 +99,11 @@ int my_decimal2string(uint mask, const my_decimal *d,
UNSIGNED. Hence the buffer for a ZEROFILLed value is the length
the user requested, plus one for a possible decimal point, plus
one if the user only wanted decimal places, but we force a leading
zero on them. Because the type is implicitly UNSIGNED, we do not
need to reserve a character for the sign. For all other cases,
fixed_prec will be 0, and my_decimal_string_length() will be called
instead to calculate the required size of the buffer.
zero on them, plus one for the '\0' terminator. Because the type
is implicitly UNSIGNED, we do not need to reserve a character for
the sign. For all other cases, fixed_prec will be 0, and
my_decimal_string_length() will be called instead to calculate the
required size of the buffer.
*/
int
length
=
(
fixed_prec
?
(
fixed_prec
+
((
fixed_prec
==
fixed_dec
)
?
1
:
0
)
+
1
)
...
...
@@ -332,7 +333,7 @@ print_decimal_buff(const my_decimal *dec, const uchar* ptr, int length)
const
char
*
dbug_decimal_as_string
(
char
*
buff
,
const
my_decimal
*
val
)
{
int
length
=
DECIMAL_MAX_STR_LENGTH
;
int
length
=
DECIMAL_MAX_STR_LENGTH
+
1
;
/* minimum size for buff */
if
(
!
val
)
return
"NULL"
;
(
void
)
decimal2string
((
decimal_t
*
)
val
,
buff
,
&
length
,
0
,
0
,
0
);
...
...
sql/my_decimal.h
View file @
a0f300a6
...
...
@@ -62,7 +62,7 @@ typedef struct st_mysql_time MYSQL_TIME;
/**
maximum length of string representation (number of maximum decimal
digits + 1 position for sign + 1 position for decimal point)
digits + 1 position for sign + 1 position for decimal point
, no terminator
)
*/
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
...
...
@@ -243,6 +243,7 @@ inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
inline
int
my_decimal_string_length
(
const
my_decimal
*
d
)
{
/* length of string representation including terminating '\0' */
return
decimal_string_size
(
d
);
}
...
...
strings/decimal.c
View file @
a0f300a6
...
...
@@ -312,8 +312,8 @@ int decimal_actual_fraction(decimal_t *from)
from - value to convert
to - points to buffer where string representation
should be stored
*to_len - in: size of to buffer
out: length of the actually written string
*to_len - in: size of to buffer
(incl. terminating '\0')
out: length of the actually written string
(excl. '\0')
fixed_precision - 0 if representation can be variable length and
fixed_decimals will not be checked in this case.
Put number as with fixed point position with this
...
...
@@ -330,6 +330,7 @@ int decimal2string(decimal_t *from, char *to, int *to_len,
int
fixed_precision
,
int
fixed_decimals
,
char
filler
)
{
/* {intg_len, frac_len} output widths; {intg, frac} places in input */
int
len
,
intg
,
frac
=
from
->
frac
,
i
,
intg_len
,
frac_len
,
fill
;
/* number digits before decimal point */
int
fixed_intg
=
(
fixed_precision
?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment