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

« back to all changes in this revision

Viewing changes to sql-common/my_time.c

  • 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) 2004-2006 MySQL AB
 
1
/*
 
2
   Copyright (c) 2004, 2011, 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
#include <my_time.h>
17
19
#include <m_string.h>
772
774
  int y= year;                                  /* may be < 0 temporarily */
773
775
  DBUG_ENTER("calc_daynr");
774
776
 
775
 
  if (y == 0 && month == 0 && day == 0)
 
777
  if (y == 0 && month == 0)
776
778
    DBUG_RETURN(0);                             /* Skip errors */
777
779
  /* Cast to int to be able to handle month == 0 */
778
780
  delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day);
783
785
  temp=(int) ((y/100+1)*3)/4;
784
786
  DBUG_PRINT("exit",("year: %d  month: %d  day: %d -> daynr: %ld",
785
787
                     y+(month <= 2),month,day,delsum+y/4-temp));
 
788
  DBUG_ASSERT(delsum+(int) y/4-temp > 0);
786
789
  DBUG_RETURN(delsum+(int) y/4-temp);
787
790
} /* calc_daynr */
788
791
 
992
995
    with unsigned time_t tmp+= shift*86400L might result in a number,
993
996
    larger then TIMESTAMP_MAX_VALUE, so another check will work.
994
997
  */
995
 
  if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
 
998
  if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tmp))
996
999
    tmp= 0;
997
1000
 
998
1001
  return (my_time_t) tmp;