From: ludo@gnu.org (Ludovic Courtès)
To: Alex Kost <alezost@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: Syslog bug
Date: Wed, 01 Apr 2015 21:51:38 +0200 [thread overview]
Message-ID: <87wq1vvd85.fsf@gnu.org> (raw)
In-Reply-To: <87zj6skwbs.fsf_-_@gmail.com> (Alex Kost's message of "Wed, 01 Apr 2015 12:54:31 +0300")
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
Alex Kost <alezost@gmail.com> 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”:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 407 bytes --]
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);)
[-- Attachment #3: Type: text/plain, Size: 753 bytes --]
> --- 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.
> 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.
Thanks for your feedback! I’ll report the issue upstream.
Ludo’.
next prev parent reply other threads:[~2015-04-01 19:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-28 13:24 [PATCHES] Syslog produces no log (just for me?) Alex Kost
2015-03-29 14:03 ` Ludovic Courtès
2015-03-30 7:23 ` Alex Kost
2015-03-30 21:20 ` Ludovic Courtès
2015-04-01 9:54 ` Syslog bug Alex Kost
2015-04-01 19:51 ` Ludovic Courtès [this message]
2015-04-01 20:34 ` Alex Kost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wq1vvd85.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).