Fix for https://github.com/rsyslog/rsyslog/issues/61

Based on Maxim Koltsov proposed patch from https://bugs.gentoo.org/show_bug.cgi?id=507730
Merge branch 'v7-stable' into v8-stable