diff mbox

iproute2: xfrm state add abort issue

Message ID 52447DAC.2060701@linux.vnet.ibm.com
State Changes Requested, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Sohny Thomas Sept. 26, 2013, 6:32 p.m. UTC
ip xfrm state add causes a SIGABRT due to a strncpy_chk .
This happens since strncpy doesn't account for the '\0' .
I have fixed this using sizeof  instead of strlen .

There is a redhat bug which documents this issue

https://bugzilla.redhat.com/show_bug.cgi?id=982761

Signed-off-by: Sohny Thomas <sohthoma@in.ibm.com>

--------------

          /* XXX: verifying both name and key is required! */


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Laight Sept. 27, 2013, 8:26 a.m. UTC | #1
> ip xfrm state add causes a SIGABRT due to a strncpy_chk .
> This happens since strncpy doesn't account for the '\0' .
> I have fixed this using sizeof  instead of strlen .
> 
> There is a redhat bug which documents this issue
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=982761
> 
> Signed-off-by: Sohny Thomas <sohthoma@in.ibm.com>
> 
> --------------
> 
> diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
> index 389942c..7dd8799 100644
> --- a/ip/xfrm_state.c
> +++ b/ip/xfrm_state.c
> @@ -117,7 +117,7 @@ static int xfrm_algo_parse(struct xfrm_algo *alg,
> enum xfrm_attr_type_t type,
>                              char *name, char *key, char *buf, int max)
>    {
>           int len;
> -       int slen = strlen(key);
> +       int slen = sizeof(key);

you definitely don't want sizeof(key) - that is either 4 or 8.

	David



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sohny Thomas Sept. 28, 2013, 1:24 p.m. UTC | #2
On Friday 27 September 2013 01:56 PM, David Laight wrote:
>> ip xfrm state add causes a SIGABRT due to a strncpy_chk .
>> This happens since strncpy doesn't account for the '\0' .
>> I have fixed this using sizeof  instead of strlen .
>>
>> There is a redhat bug which documents this issue
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=982761
>>
>> Signed-off-by: Sohny Thomas <sohthoma@in.ibm.com>
>>
>> --------------
>>
>> diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
>> index 389942c..7dd8799 100644
>> --- a/ip/xfrm_state.c
>> +++ b/ip/xfrm_state.c
>> @@ -117,7 +117,7 @@ static int xfrm_algo_parse(struct xfrm_algo *alg,
>> enum xfrm_attr_type_t type,
>>                               char *name, char *key, char *buf, int max)
>>     {
>>            int len;
>> -       int slen = strlen(key);
>> +       int slen = sizeof(key);
>
> you definitely don't want sizeof(key) - that is either 4 or 8.
oh damn my bad.
I think i will go with strlen(key) + 1.

or i will pass slen+1 to strncpy .

Regards,
Sohny
>
> 	David
>
>
>
>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index 389942c..7dd8799 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -117,7 +117,7 @@  static int xfrm_algo_parse(struct xfrm_algo *alg, 
enum xfrm_attr_type_t type,
                             char *name, char *key, char *buf, int max)
   {
          int len;
-       int slen = strlen(key);
+       int slen = sizeof(key);

   #if 0