mirror of
https://github.com/nmap/nmap.git
synced 2026-01-18 12:19:02 +00:00
FIx SSL certificate date parsing to subtract 1 from the month to fit the
convention of a struct tm. The bug was reported by Matt Selsky.
This commit is contained in:
@@ -280,6 +280,10 @@ static int time_to_tm(const ASN1_TIME *t, struct tm *result)
|
||||
}
|
||||
|
||||
result->tm_mon = parse_int(p, 2);
|
||||
/* struct tm uses zero-indexed months. */
|
||||
if (result->tm_mon == 0)
|
||||
return -1;
|
||||
result->tm_mon--;
|
||||
result->tm_mday = parse_int(p + 2, 2);
|
||||
result->tm_hour = parse_int(p + 4, 2);
|
||||
result->tm_min = parse_int(p + 6, 2);
|
||||
@@ -302,6 +306,7 @@ static void tm_to_table(lua_State *L, const struct tm *tm)
|
||||
|
||||
lua_pushnumber(L, tm->tm_year);
|
||||
lua_setfield(L, -2, "year");
|
||||
/* Lua uses one-indexed months. */
|
||||
lua_pushnumber(L, tm->tm_mon + 1);
|
||||
lua_setfield(L, -2, "month");
|
||||
lua_pushnumber(L, tm->tm_mday);
|
||||
|
||||
Reference in New Issue
Block a user