~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to sql/my_decimal.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2005-2006 MySQL AB
 
1
/*
 
2
   Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/**
17
19
  @file
55
57
 
56
58
/**
57
59
  maximum length of string representation (number of maximum decimal
58
 
  digits + 1 position for sign + 1 position for decimal point)
 
60
  digits + 1 position for sign + 1 position for decimal point, no terminator)
59
61
*/
60
62
#define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_POSSIBLE_PRECISION + 2)
61
63
 
91
93
 
92
94
class my_decimal :public decimal_t
93
95
{
 
96
  /*
 
97
    Several of the routines in strings/decimal.c have had buffer
 
98
    overrun/underrun problems. These are *not* caught by valgrind.
 
99
    To catch them, we allocate dummy fields around the buffer,
 
100
    and test that their values do not change.
 
101
   */
 
102
#if !defined(DBUG_OFF)
 
103
  int foo1;
 
104
#endif
 
105
 
94
106
  decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
95
107
 
 
108
#if !defined(DBUG_OFF)
 
109
  int foo2;
 
110
  static const int test_value= 123;
 
111
#endif
 
112
 
96
113
public:
97
114
 
98
115
  void init()
99
116
  {
 
117
#if !defined(DBUG_OFF)
 
118
    foo1= test_value;
 
119
    foo2= test_value;
 
120
#endif
100
121
    len= DECIMAL_BUFF_LENGTH;
101
122
    buf= buffer;
102
 
#if !defined (HAVE_purify) && !defined(DBUG_OFF)
103
 
    /* Set buffer to 'random' value to find wrong buffer usage */
104
 
    for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++)
105
 
      buffer[i]= i;
106
 
#endif
107
123
  }
 
124
 
108
125
  my_decimal()
109
126
  {
110
127
    init();
111
128
  }
 
129
  ~my_decimal()
 
130
  {
 
131
    sanity_check();
 
132
  }
 
133
 
 
134
  void sanity_check()
 
135
  {
 
136
    DBUG_ASSERT(foo1 == test_value);
 
137
    DBUG_ASSERT(foo2 == test_value);
 
138
  }
 
139
 
112
140
  void fix_buffer_pointer() { buf= buffer; }
113
141
 
114
142
  bool sign() const { return decimal_t::sign; }
212
240
inline
213
241
int my_decimal_string_length(const my_decimal *d)
214
242
{
 
243
  /* length of string representation including terminating '\0' */
215
244
  return decimal_string_size(d);
216
245
}
217
246