All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Schaaf <bof@bof.de>
To: Arvanitis Kostas <arvanit@ellemedia.com>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Buffer of by one in iptables.c in iptables v1.2.7a
Date: Sun, 23 Feb 2003 12:41:50 +0100	[thread overview]
Message-ID: <20030223114150.GF18918@oknodo.bof.de> (raw)
In-Reply-To: <200302211624.05704.arvanit@ellemedia.com>

On Fri, Feb 21, 2003 at 04:24:05PM +0200, Arvanitis Kostas wrote:
> The line in find_target() that reads:
> 
> char path[sizeof(IPT_LIB_DIR) + sizeof("/libipt_.so") + strlen(name)]
> 
> is used as the target buffer for a sprintf() statement.

That is probably correct, although a bit subtle.

You did not show the format string used later, and I'm too lazy do
dig for the source, but I guess it will be something like

	sprintf(path, IPT_LIB_DIR "/libipt_%s.so", name);

Right?

Now, count the characters again, with an eye not on the path[sizeof]
stuff, but on the actual format string. Note how the value of 'name'
will be embedded in the formatted string: it does not need a '\0' in
that representation.

Also note that the two sizeofs each contribute one '\0' (their args
being constant C strings), but only one of them is needed for
sprintf() to properly terminate the result. So, if I don't
miscount, there's even one surplus byte in path[].

This should fix that:

	char path[sizeof(IPT_LIB_DIR "/libipt_.so") + strlen(name)]

best regards
  Patrick

      reply	other threads:[~2003-02-23 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-21 14:24 Buffer of by one in iptables.c in iptables v1.2.7a Arvanitis Kostas
2003-02-23 11:41 ` Patrick Schaaf [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=20030223114150.GF18918@oknodo.bof.de \
    --to=bof@bof.de \
    --cc=arvanit@ellemedia.com \
    --cc=netfilter-devel@lists.netfilter.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.
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.