View | Details | Raw Unified | Return to bug 54774
Collapse All | Expand All

(-)src/ne_dates.c (-4 / +4 lines)
Lines 47-53 Link Here
47
/* RFC1123: Sun, 06 Nov 1994 08:49:37 GMT */
47
/* RFC1123: Sun, 06 Nov 1994 08:49:37 GMT */
48
#define RFC1123_FORMAT "%3s, %02d %3s %4d %02d:%02d:%02d GMT"
48
#define RFC1123_FORMAT "%3s, %02d %3s %4d %02d:%02d:%02d GMT"
49
/* RFC850:  Sunday, 06-Nov-94 08:49:37 GMT */
49
/* RFC850:  Sunday, 06-Nov-94 08:49:37 GMT */
50
#define RFC1036_FORMAT "%s %2d-%3s-%2d %2d:%2d:%2d GMT"
50
#define RFC1036_FORMAT "%10s %2d-%3s-%2d %2d:%2d:%2d GMT"
51
/* asctime: Wed Jun 30 21:49:08 1993 */
51
/* asctime: Wed Jun 30 21:49:08 1993 */
52
#define ASCTIME_FORMAT "%3s %3s %2d %2d:%2d:%2d %4d"
52
#define ASCTIME_FORMAT "%3s %3s %2d %2d:%2d:%2d %4d"
53
53
Lines 133-139 Link Here
133
time_t ne_rfc1123_parse(const char *date) 
133
time_t ne_rfc1123_parse(const char *date) 
134
{
134
{
135
    struct tm gmt = {0};
135
    struct tm gmt = {0};
136
    static char wkday[4], mon[4];
136
    char wkday[4], mon[4];
137
    int n;
137
    int n;
138
/*  it goes: Sun, 06 Nov 1994 08:49:37 GMT */
138
/*  it goes: Sun, 06 Nov 1994 08:49:37 GMT */
139
    n = sscanf(date, RFC1123_FORMAT,
139
    n = sscanf(date, RFC1123_FORMAT,
Lines 156-162 Link Here
156
{
156
{
157
    struct tm gmt = {0};
157
    struct tm gmt = {0};
158
    int n;
158
    int n;
159
    static char wkday[10], mon[4];
159
    char wkday[11], mon[4];
160
    /* RFC850/1036 style dates: Sunday, 06-Nov-94 08:49:37 GMT */
160
    /* RFC850/1036 style dates: Sunday, 06-Nov-94 08:49:37 GMT */
161
    n = sscanf(date, RFC1036_FORMAT,
161
    n = sscanf(date, RFC1036_FORMAT,
162
		wkday, &gmt.tm_mday, mon, &gmt.tm_year,
162
		wkday, &gmt.tm_mday, mon, &gmt.tm_year,
Lines 189-195 Link Here
189
{
189
{
190
    struct tm gmt = {0};
190
    struct tm gmt = {0};
191
    int n;
191
    int n;
192
    static char wkday[4], mon[4];
192
    char wkday[4], mon[4];
193
    n = sscanf(date, ASCTIME_FORMAT,
193
    n = sscanf(date, ASCTIME_FORMAT,
194
		wkday, mon, &gmt.tm_mday, 
194
		wkday, mon, &gmt.tm_mday, 
195
		&gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec,
195
		&gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec,
(-)test/util-tests.c (-1 / +20 lines)
Lines 1-6 Link Here
1
/* 
1
/* 
2
   utils tests
2
   utils tests
3
   Copyright (C) 2001-2003, Joe Orton <joe@manyfish.co.uk>
3
   Copyright (C) 2001-2004, Joe Orton <joe@manyfish.co.uk>
4
4
5
   This program is free software; you can redistribute it and/or modify
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
6
   it under the terms of the GNU General Public License as published by
Lines 165-170 Link Here
165
} good_dates[] = {
165
} good_dates[] = {
166
    { "Fri, 08 Jun 2001 22:59:46 GMT", 992041186, d_rfc1123 },
166
    { "Fri, 08 Jun 2001 22:59:46 GMT", 992041186, d_rfc1123 },
167
    { "Friday, 08-Jun-01 22:59:46 GMT", 992041186, d_rfc1036 },
167
    { "Friday, 08-Jun-01 22:59:46 GMT", 992041186, d_rfc1036 },
168
    { "Wednesday, 06-Jun-01 22:59:46 GMT", 991868386, d_rfc1036 },
168
    /* some different types of ISO8601 dates. */
169
    /* some different types of ISO8601 dates. */
169
    { "2001-06-08T22:59:46Z", 992041186, d_iso8601 },
170
    { "2001-06-08T22:59:46Z", 992041186, d_iso8601 },
170
    { "2001-06-08T22:59:46.9Z", 992041186, d_iso8601 },
171
    { "2001-06-08T22:59:46.9Z", 992041186, d_iso8601 },
Lines 199-204 Link Here
199
    return OK;
200
    return OK;
200
}
201
}
201
202
203
/* trigger segfaults in ne_rfc1036_parse() in <=0.24.5. */
204
static int regress_dates(void)
205
{
206
    static const char *dates[] = {
207
        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
208
    };
209
    size_t n;
210
    
211
    for (n = 0; n < sizeof(dates)/sizeof(dates[0]); n++) {
212
        ne_rfc1036_parse(dates[n]);
213
        ne_iso8601_parse(dates[n]);
214
        ne_rfc1123_parse(dates[n]);
215
    }
216
217
    return OK;
218
}
219
202
static int versioning(void)
220
static int versioning(void)
203
{
221
{
204
#define GOOD(n,m,msg) ONV(ne_version_match(n,m), \
222
#define GOOD(n,m,msg) ONV(ne_version_match(n,m), \
Lines 249-254 Link Here
249
    T(md5),
267
    T(md5),
250
    T(md5_alignment),
268
    T(md5_alignment),
251
    T(parse_dates),
269
    T(parse_dates),
270
    T(regress_dates),
252
    T(versioning),
271
    T(versioning),
253
    T(version_string),
272
    T(version_string),
254
    T(support),
273
    T(support),

Return to bug 54774