~ubuntu-branches/ubuntu/trusty/xulrunner/trusty

« back to all changes in this revision

Viewing changes to security/nss/lib/util/dertime.c

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-25 13:04:18 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080825130418-ck1i2ms384tzb9m0
Tags: 1.8.1.16+nobinonly-0ubuntu1
* New upstream release (taken from upstream CVS), LP: #254618.
* Fix MFSA 2008-35, MFSA 2008-34, MFSA 2008-33, MFSA 2008-32, MFSA 2008-31,
  MFSA 2008-30, MFSA 2008-29, MFSA 2008-28, MFSA 2008-27, MFSA 2008-25,
  MFSA 2008-24, MFSA 2008-23, MFSA 2008-22, MFSA 2008-21, MFSA 2008-26 also
  known as CVE-2008-2933, CVE-2008-2785, CVE-2008-2811, CVE-2008-2810,
  CVE-2008-2809, CVE-2008-2808, CVE-2008-2807, CVE-2008-2806, CVE-2008-2805,
  CVE-2008-2803, CVE-2008-2802, CVE-2008-2801, CVE-2008-2800, CVE-2008-2798.
* Drop 89_bz419350_attachment_306066 patch, merged upstream.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
    31+28+31+30+31+30+31+31+30+31+30,
75
75
};
76
76
 
 
77
static const PRTime January1st1     = (PRTime) LL_INIT(0xff234001U, 0x00d44000U);
 
78
static const PRTime January1st1950  = (PRTime) LL_INIT(0xfffdc1f8U, 0x793da000U);
 
79
static const PRTime January1st2050  = LL_INIT(0x0008f81e, 0x1b098000);
 
80
static const PRTime January1st10000 = LL_INIT(0x0384440c, 0xcc736000);
 
81
 
77
82
/* gmttime must contains UTC time in micro-seconds unit */
78
83
SECStatus
79
84
DER_TimeToUTCTimeArena(PRArenaPool* arenaOpt, SECItem *dst, int64 gmttime)
81
86
    PRExplodedTime printableTime;
82
87
    unsigned char *d;
83
88
 
 
89
    if ( (gmttime < January1st1950) || (gmttime >= January1st2050) ) {
 
90
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
 
91
        return SECFailure;
 
92
    }
 
93
 
84
94
    dst->len = 13;
85
95
    if (arenaOpt) {
86
96
        dst->data = d = (unsigned char*) PORT_ArenaAlloc(arenaOpt, dst->len);
98
108
    /* The month in UTC time is base one */
99
109
    printableTime.tm_month++;
100
110
 
101
 
    /* UTC time does not handle the years before 1950 */
102
 
    if (printableTime.tm_year < 1950)
103
 
            return SECFailure;
104
 
 
105
111
    /* remove the century since it's added to the tm_year by the 
106
112
       PR_ExplodeTime routine, but is not needed for UTC time */
107
113
    printableTime.tm_year %= 100; 
269
275
    PRExplodedTime printableTime;
270
276
    unsigned char *d;
271
277
 
 
278
    if ( (gmttime<January1st1) || (gmttime>=January1st10000) ) {
 
279
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
 
280
        return SECFailure;
 
281
    }
272
282
    dst->len = 15;
273
283
    if (arenaOpt) {
274
284
        dst->data = d = (unsigned char*) PORT_ArenaAlloc(arenaOpt, dst->len);
280
290
        return SECFailure;
281
291
    }
282
292
 
283
 
    /*Convert a int64 time to a printable format. This is a temporary call
284
 
          until we change to NSPR 2.0
285
 
     */
 
293
    /* Convert an int64 time to a printable format.  */
286
294
    PR_ExplodeTime(gmttime, PR_GMTParameters, &printableTime);
287
295
 
288
296
    /* The month in Generalized time is base one */