[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syslog bug
From: |
Alex Kost |
Subject: |
Re: Syslog bug |
Date: |
Wed, 01 Apr 2015 23:34:56 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Ludovic Courtès (2015-04-01 22:51 +0300) wrote:
> Alex Kost <address@hidden> skribis:
>
>> Wow, I admire how deep you dig! Your patch does some funny thing, it
>> "moves" corruption to another place. Here is the output:
>>
>> # ./syslogd --debug --rcfile /tmp/syslog-with-leading-spaces.conf
>> init
>> cfline(*.alert;auth.notice;authpriv.none /dev/console
>> sole)
>
> Oops, indeed, I had it too but hadn’t noticed. :-)
>
> This is because the bcopy call didn’t copy the trailing zero, which is
> fixed by adding “+ 1”:
>
>
> diff --git a/src/syslogd.c b/src/syslogd.c
> index 7af10f3..aaf02a4 100644
> --- a/src/syslogd.c
> +++ b/src/syslogd.c
> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed
> **nextp)
> if (*p == '\0' || *p == '#')
> continue;
>
> - strcpy (cline, p);
> + bcopy (p, cline, strlen (p) + 1);
>
> /* Cut the trailing spaces. */
> for (p = strchr (cline, '\0'); isspace (*--p);)
OK, btw the manual (info "(libc) Copying and Concatenation") says
'bcopy' «is a partially obsolete alternative for 'memmove'».
>> --- a/src/syslogd.c
>> +++ b/src/syslogd.c
>> @@ -1971,7 +1971,7 @@ load_conffile (const char *filename, struct filed
>> **nextp)
>> if (*p == '\0' || *p == '#')
>> continue;
>>
>> - strcpy (cline, p);
>> + strncpy (cline, p, strlen (cline));
>
> I guess this worked by chance: it does not copy the trailing zero, and
> it doesn’t address the overlapping-memory-regions issue.
By chance? I thought it's reliable as it would fill the redundant part
of 'cline' (the rest part after copying 'p') with null characters.
>> A side note: compilation of inetutils failed for me complaining about
>> missing "help2man". It finished successfully after I had added
>> "help2man" to native-inputs.
>
> That’s because the patch modifies the source of an executable for which
> a man page is generated.
Ah, thanks for the explanation.
> Thanks for your feedback! I’ll report the issue upstream.
Great, thank you!
--
Alex