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

Stats freq overflow #3320

Merged
merged 3 commits into from
Jun 12, 2020
Merged

Stats freq overflow #3320

merged 3 commits into from
Jun 12, 2020

Conversation

Kokan
Copy link
Collaborator

@Kokan Kokan commented Jun 12, 2020

The current stats-freq option could go as high as 2^31-1 (which of course kinda unrealistic), but the opposite happens, the stats reports start to spawn right away in an infinite loop manner.

When timer is adjusted (timespec_add_msec(&timer->expires, freq * 1000);) the freq * 1000 is used, where the freq has the type gint, and the function - correctly - waits a glong, but the multiplication happens before the parameter assignment and in the domain of gint that yields gint overflow.

The gint freq could hold the value 2^31-1, that later used in the code as:
```
timespec_add_msec(&timer->expires, freq * 1000);
```
While the timespec_add_msec last argument is a glong that could hold 1000*2^31-1,
the multiplication happens in the gint domain, which overflows yielding a
negative number. Causing the timer imidiate trigger.

Signed-off-by: Kokan <[email protected]>
@Kokan Kokan added this to the syslog-ng-3.28 milestone Jun 12, 2020
@Kokan Kokan marked this pull request as ready for review June 12, 2020 13:06
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@lbudai lbudai merged commit 55955c9 into syslog-ng:master Jun 12, 2020
@Kokan Kokan deleted the stats-freq-overflow branch June 12, 2020 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants