Skip to content

Commit

Permalink
Merge pull request #461 from jjnicola/isotime-warn
Browse files Browse the repository at this point in the history
Fix format-truncation warning in GCC 8.2 and later.
  • Loading branch information
jjnicola authored Mar 9, 2020
2 parents 3a635e9 + 04823a8 commit 33771fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Create greenbone-nvt-sync create lock file during feed sync.
[#458](https://github.com/greenbone/openvas/pull/458)
[#459](https://github.com/greenbone/openvas/pull/459)
- Fix format-truncation warning in GCC 8.2 and later. [#461](https://github.com/greenbone/openvas/pull/461)

### Changed
- The logging of the NASL internal regexp functions was extended to include the pattern in case of a failed regcomp(). [#397](https://github.com/greenbone/openvas/pull/397)
Expand Down
31 changes: 22 additions & 9 deletions nasl/nasl_isotime.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ epoch2isotime (my_isotime_t timebuf, time_t atime)
struct tm *tp;

tp = gmtime (&atime);
snprintf (timebuf, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d",
1900 + tp->tm_year, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour,
tp->tm_min, tp->tm_sec);
if (snprintf (timebuf, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d",
1900 + tp->tm_year, tp->tm_mon + 1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec)
< 0)
{
*timebuf = '\0';
return;
}
}
}

Expand Down Expand Up @@ -433,8 +438,11 @@ add_seconds_to_isotime (my_isotime_t atime, int nseconds)
if (year > 9999 || month > 12 || day > 31 || year < 0 || month < 1 || day < 1)
return 1;

snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month, day,
hour, minute, sec);
if (snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month,
day, hour, minute, sec)
< 0)
return 1;

return 0;
}

Expand Down Expand Up @@ -469,8 +477,10 @@ add_days_to_isotime (my_isotime_t atime, int ndays)
if (year > 9999 || month > 12 || day > 31 || year < 0 || month < 1 || day < 1)
return 1;

snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month, day,
hour, minute, sec);
if (snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month,
day, hour, minute, sec)
< 0)
return 1;
return 0;
}

Expand Down Expand Up @@ -505,8 +515,11 @@ add_years_to_isotime (my_isotime_t atime, int nyears)
if (year > 9999 || month > 12 || day > 31 || year < 0 || month < 1 || day < 1)
return 1;

snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month, day,
hour, minute, sec);
if (snprintf (atime, ISOTIME_SIZE, "%04d%02d%02dT%02d%02d%02d", year, month,
day, hour, minute, sec)
< 0)
return 1;

return 0;
}

Expand Down

0 comments on commit 33771fa

Please sign in to comment.