Author: mattm Date: 2017-01-13 16:26:40 +0100 (Fri, 13 Jan 2017) New Revision: 27209
Modified: branches/openvas-manager-7.0/ChangeLog branches/openvas-manager-7.0/src/manage_sql.c branches/openvas-manager-7.0/src/manage_sqlite3.c Log: Backport r27203. * src/manage_sql.c (parse_ctime, parse_iso_time, parse_time) (parse_keyword, host_summary_append): Always clear the struct tm before doing a strptime. Even do so after a previous call of strptime returned NULL, just to be sure. * src/manage_sqlite3.c (migrate_51_to_52_sql_convert): Ditto. Modified: branches/openvas-manager-7.0/ChangeLog =================================================================== --- branches/openvas-manager-7.0/ChangeLog 2017-01-13 14:14:38 UTC (rev 27208) +++ branches/openvas-manager-7.0/ChangeLog 2017-01-13 15:26:40 UTC (rev 27209) @@ -1,3 +1,14 @@ +2017-01-13 Matthew Mundell <matthew.mund...@greenbone.net> + + Backport r27203. + + * src/manage_sql.c (parse_ctime, parse_iso_time, parse_time) + (parse_keyword, host_summary_append): Always clear the struct tm before + doing a strptime. Even do so after a previous call of strptime returned + NULL, just to be sure. + + * src/manage_sqlite3.c (migrate_51_to_52_sql_convert): Ditto. + 2017-01-04 Timo Pollmeier <timo.pollme...@greenbone.net> Backport r27107. Modified: branches/openvas-manager-7.0/src/manage_sql.c =================================================================== --- branches/openvas-manager-7.0/src/manage_sql.c 2017-01-13 14:14:38 UTC (rev 27208) +++ branches/openvas-manager-7.0/src/manage_sql.c 2017-01-13 15:26:40 UTC (rev 27209) @@ -813,6 +813,7 @@ /* ctime format: "Wed Jun 30 21:49:08 1993". */ + memset (&tm, 0, sizeof (struct tm)); if (strptime ((char*) text_time, "%a %b %d %H:%M:%S %Y", &tm) == NULL) { g_warning ("%s: Failed to parse time", __FUNCTION__); @@ -843,17 +844,21 @@ { int epoch_time; struct tm tm; + memset (&tm, 0, sizeof (struct tm)); tm.tm_isdst = -1; - if (strptime ((char*) text_time, "%FT%T%z", &tm) == NULL) { gchar *tz; + memset (&tm, 0, sizeof (struct tm)); + tm.tm_isdst = -1; if (strptime ((char*) text_time, "%FT%TZ", &tm) == NULL) { /* Try time without timezone suffix, applying timezone of user */ + memset (&tm, 0, sizeof (struct tm)); + tm.tm_isdst = -1; if (strptime ((char*) text_time, "%FT%T", &tm) == NULL) return parse_ctime (text_time); @@ -870,6 +875,8 @@ return 0; } + memset (&tm, 0, sizeof (struct tm)); + tm.tm_isdst = -1; if (strptime ((char*) text_time, "%FT%T", &tm) == NULL) { assert (0); @@ -896,6 +903,8 @@ return 0; } + memset (&tm, 0, sizeof (struct tm)); + tm.tm_isdst = -1; if (strptime ((char*) text_time, "%FT%TZ", &tm) == NULL) { assert (0); @@ -978,6 +987,8 @@ /* Parse time again under the new timezone. */ + memset (&tm, 0, sizeof (struct tm)); + tm.tm_isdst = -1; if (strptime ((char*) text_time, "%FT%T%z", &tm) == NULL) { assert (0); @@ -1416,14 +1427,30 @@ /* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */ /* $Date: 2012-02-17 16:05:26 +0100 (Fr, 17. Feb 2012) $ */ /* $Date: Fri, 11 Nov 2011 14:42:28 +0100 $ */ - if ((strptime ((char*) string, "%F %T %z", &tm) == NULL) - && (strptime ((char*) string, "$Date: %F %T %z", &tm) == NULL) - && (strptime ((char*) string, "%a %b %d %T %Y %z", &tm) == NULL) - && (strptime ((char*) string, "$Date: %a, %d %b %Y %T %z", &tm) == NULL) - && (strptime ((char*) string, "$Date: %a %b %d %T %Y %z", &tm) == NULL)) + memset (&tm, 0, sizeof (struct tm)); + if (strptime ((char*) string, "%F %T %z", &tm) == NULL) { - g_warning ("%s: Failed to parse time: %s", __FUNCTION__, string); - return -1; + memset (&tm, 0, sizeof (struct tm)); + if (strptime ((char*) string, "$Date: %F %T %z", &tm) == NULL) + { + memset (&tm, 0, sizeof (struct tm)); + if (strptime ((char*) string, "%a %b %d %T %Y %z", &tm) == NULL) + { + memset (&tm, 0, sizeof (struct tm)); + if (strptime ((char*) string, "$Date: %a, %d %b %Y %T %z", &tm) + == NULL) + { + memset (&tm, 0, sizeof (struct tm)); + if (strptime ((char*) string, "$Date: %a %b %d %T %Y %z", &tm) + == NULL) + { + g_warning ("%s: Failed to parse time: %s", + __FUNCTION__, string); + return -1; + } + } + } + } } epoch_time = mktime (&tm); if (epoch_time == -1) @@ -1747,7 +1774,8 @@ keyword->integer_value = mktime (&date); keyword->type = KEYWORD_TYPE_INTEGER; } - else if (strptime (keyword->string, "%Y-%m-%d", &date)) + else if (memset (&date, 0, sizeof (date)), + strptime (keyword->string, "%Y-%m-%d", &date)) { keyword->integer_value = mktime (&date); keyword->type = KEYWORD_TYPE_INTEGER; @@ -26499,6 +26527,7 @@ struct tm start_tm, end_tm; char start[200], end[200]; + memset (&start_tm, 0, sizeof (struct tm)); if (strptime (start_iso, "%FT%H:%M:%S", &start_tm) == NULL) { g_warning ("%s: Failed to parse start", __FUNCTION__); @@ -26511,6 +26540,7 @@ return; } + memset (&start_tm, 0, sizeof (struct tm)); if (strptime (end_iso, "%FT%H:%M:%S", &end_tm) == NULL) { g_warning ("%s: Failed to parse end", __FUNCTION__); Modified: branches/openvas-manager-7.0/src/manage_sqlite3.c =================================================================== --- branches/openvas-manager-7.0/src/manage_sqlite3.c 2017-01-13 14:14:38 UTC (rev 27208) +++ branches/openvas-manager-7.0/src/manage_sqlite3.c 2017-01-13 15:26:40 UTC (rev 27209) @@ -3313,6 +3313,7 @@ */ if (text_time && (strlen ((char*) text_time) > 0)) { + memset (&tm, 0, sizeof (struct tm)); if (strptime ((char*) text_time, "%a %b %d %H:%M:%S %Y", &tm) == NULL) { sqlite3_result_error (context, "Failed to parse time", -1); _______________________________________________ Openvas-commits mailing list Openvas-commits@wald.intevation.org https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits