All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Bin Li <libin.charles@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] iproute2: Conforming to -D_FORTIFY_SOURCE=2 restrictions
Date: Mon, 17 Oct 2011 08:23:07 -0700	[thread overview]
Message-ID: <20111017082307.46a994a8@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <CAGBH1r6P_nmVhSQ7d9sj1qU_1VY7QssWm3ftS4mNcQjyAuCcqA@mail.gmail.com>

On Mon, 17 Oct 2011 15:35:35 +0800
Bin Li <libin.charles@gmail.com> wrote:

> (gdb) l
> 161                     len = slen;
> 162                     if (len > 0) {
> 163                             if (len > max)
> 164                                     invarg("\"ALGOKEY\" makes buffer
> overflow\n", key);
> 165
> 166                             strncpy(buf, key, len);
> 167                     }
> 168             }
> 169
> 170             alg->alg_key_len = len * 8;
> (gdb) up
> #8  xfrm_state_modify (cmd=<optimized out>, flags=<optimized out>, argc=1,
>     argv=0x7fffffffe370) at xfrm_state.c:406
> 406                                     xfrm_algo_parse((void *)&alg, type,
> name, key,
> 
> the compiler passes zero to __builtin___strncpy_chk as the buffer size.
> xfrm_algo_parse is inlined into xfrm_state_modify.

I don't understand, looks like a compiler bug. Call strncpy with
0 length should not be possible since the check was  3 lines
before for len > 0.

  reply	other threads:[~2011-10-17 15:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17  7:35 [PATCH] iproute2: Conforming to -D_FORTIFY_SOURCE=2 restrictions Bin Li
2011-10-17 15:23 ` Stephen Hemminger [this message]
2011-10-19  9:15   ` Bin Li
2011-10-19 11:30     ` Eric Dumazet
2011-10-19 16:50       ` Stephen Hemminger

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=20111017082307.46a994a8@nehalam.linuxnetplumber.net \
    --to=shemminger@vyatta.com \
    --cc=libin.charles@gmail.com \
    --cc=netdev@vger.kernel.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.