all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Syslog bug
Date: Wed, 01 Apr 2015 23:34:56 +0300	[thread overview]
Message-ID: <87384joadr.fsf@gmail.com> (raw)
In-Reply-To: <87wq1vvd85.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 01 Apr 2015 21:51:38 +0200")

Ludovic Courtès (2015-04-01 22:51 +0300) wrote:

> 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”:
>
>
> 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

      reply	other threads:[~2015-04-01 20:35 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
2015-04-01 20:34           ` Alex Kost [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87384joadr.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.