Skip to content

Commit 50a509b

Browse files
authored
Merge pull request #250 from freeswitch/leap
Fix msg_date_d and msg_date_e wrongly parsing dates after 29 Feb. Mon returned by month_d() is in 0..11 range. Fix unit-tests that were assuming 25 Mar 2004 to be Wednesday but it's actually Thursday.
2 parents aa96cbc + 17aaa40 commit 50a509b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libsofia-sip-ua/msg/msg_date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ issize_t msg_date_d(char const **ss, msg_time_t *date)
296296
(min + 60 *
297297
(hour + 24 *
298298
(day - 1 + mon * 30 + first_day_offset[mon] +
299-
(leap_year && mon > 2) + ydays)));
299+
(leap_year && mon > 1) + ydays)));
300300
}
301301
*ss = s;
302302

@@ -357,7 +357,7 @@ issize_t msg_date_e(char b[], isize_t bsiz, msg_time_t http_date)
357357
while (day >= days_per_month) {
358358
day -= days_per_month;
359359
month++;
360-
days_per_month = days_per_months[month] + (leap_year && month == 2);
360+
days_per_month = days_per_months[month] + (leap_year && month == 1);
361361
}
362362

363363
return snprintf(b, bsiz, "%s, %02ld %s %04ld %02ld:%02ld:%02ld GMT",

libsofia-sip-ua/sip/torture_sip.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ int test_basic(void)
743743
TEST_1(ex = sip_expires_make(home, "4294967297")); /* XXX */
744744
su_free(home, ex);
745745

746-
TEST_1(ex = sip_expires_make(home, "Wed, 25 Mar 2004 14:49:29 GMT"));
746+
TEST_1(ex = sip_expires_make(home, "Thu, 25 Mar 2004 14:49:29 GMT"));
747747
su_free(home, ex);
748748

749749
TEST_1(ex = sip_expires_create(home, 3600));
@@ -1034,7 +1034,7 @@ static int test_encoding(void)
10341034
"Extension-Header: extended, more\r\n"
10351035
"Reason: Q.850;cause=16;text=\"Terminated\"\r\n"
10361036
"Contact: <sip:[email protected]:5060>\r\n"
1037-
"Date: Wed, 25 Mar 2004 14:49:29 GMT\r\n"
1037+
"Date: Thu, 25 Mar 2004 14:49:29 GMT\r\n"
10381038
"Max-Forwards: 80\r\n"
10391039
"Min-Expires: 30\r\n"
10401040
"Retry-After: 48 (this is a comment) ;duration=321\r\n"
@@ -1109,10 +1109,10 @@ static int test_encoding(void)
11091109
"Extension-Header: extended, more\r\n"
11101110
"Reason: SIP;cause=400;text=\"Bad Message\"\r\n"
11111111
"Contact: <sip:[email protected]:5060>;audio\r\n"
1112-
"Date: Wed, 25 Mar 2004 14:49:29 GMT\r\n"
1112+
"Date: Thu, 25 Mar 2004 14:49:29 GMT\r\n"
11131113
"Max-Forwards: 80\r\n"
11141114
"Min-Expires: 30\r\n"
1115-
"Expires: Wed, 25 Mar 2004 15:49:29 GMT\r\n"
1115+
"Expires: Thu, 25 Mar 2004 15:49:29 GMT\r\n"
11161116
"Retry-After: 48;duration=321\r\n"
11171117
"Record-Route: <sip:[email protected];maddr=172.21.40.40>\r\n"
11181118
"Event: presence;id=1\r\n"

0 commit comments

Comments
 (0)