Skip to content

Commit

Permalink
Fix msg_date_d and msg_date_e wrongly parsing dates after 29 Feb. Mon…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
andywolk committed Mar 1, 2024
1 parent aa96cbc commit 7e68aee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libsofia-sip-ua/msg/msg_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ issize_t msg_date_d(char const **ss, msg_time_t *date)
(min + 60 *
(hour + 24 *
(day - 1 + mon * 30 + first_day_offset[mon] +
(leap_year && mon > 2) + ydays)));
(leap_year && mon > 1) + ydays)));
}
*ss = s;

Expand Down Expand Up @@ -357,7 +357,7 @@ issize_t msg_date_e(char b[], isize_t bsiz, msg_time_t http_date)
while (day >= days_per_month) {
day -= days_per_month;
month++;
days_per_month = days_per_months[month] + (leap_year && month == 2);
days_per_month = days_per_months[month] + (leap_year && month == 1);
}

return snprintf(b, bsiz, "%s, %02ld %s %04ld %02ld:%02ld:%02ld GMT",
Expand Down
6 changes: 3 additions & 3 deletions libsofia-sip-ua/sip/torture_sip.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ int test_basic(void)
TEST_1(ex = sip_expires_make(home, "4294967297")); /* XXX */
su_free(home, ex);

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

TEST_1(ex = sip_expires_create(home, 3600));
Expand Down Expand Up @@ -1034,7 +1034,7 @@ static int test_encoding(void)
"Extension-Header: extended, more\r\n"
"Reason: Q.850;cause=16;text=\"Terminated\"\r\n"
"Contact: <sip:[email protected]:5060>\r\n"
"Date: Wed, 25 Mar 2004 14:49:29 GMT\r\n"
"Date: Thu, 25 Mar 2004 14:49:29 GMT\r\n"
"Max-Forwards: 80\r\n"
"Min-Expires: 30\r\n"
"Retry-After: 48 (this is a comment) ;duration=321\r\n"
Expand Down Expand Up @@ -1109,7 +1109,7 @@ static int test_encoding(void)
"Extension-Header: extended, more\r\n"
"Reason: SIP;cause=400;text=\"Bad Message\"\r\n"
"Contact: <sip:[email protected]:5060>;audio\r\n"
"Date: Wed, 25 Mar 2004 14:49:29 GMT\r\n"
"Date: Thu, 25 Mar 2004 14:49:29 GMT\r\n"
"Max-Forwards: 80\r\n"
"Min-Expires: 30\r\n"
"Expires: Wed, 25 Mar 2004 15:49:29 GMT\r\n"
Expand Down

0 comments on commit 7e68aee

Please sign in to comment.