Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format-truncation warning in GCC 8.2 and later. #461

Merged
merged 3 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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