All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@lists.osdl.org,
	tipc-discussion@lists.sourceforge.net, netdev@vger.kernel.org
Subject: Re: [KJ] [patch] net/tipc: sprintf/strcpy conversion
Date: Wed, 01 Nov 2006 21:38:26 +0000	[thread overview]
Message-ID: <454913D2.9050608@bfs.de> (raw)
In-Reply-To: <20061101140624.GA7694@Chamillionaire.breakpoint.cc>


hi Florian,

These line
+	strcpy(bcbearer->media.name, "tipc-multicast");

i gues that means tipc_bclink_name ?
an even more secure version could be like this:

	strncpy(bcbearer->media.name,sizeof(bcbearer->media.name),tipc_bclink_name);

(in case someone ever changes the size of cbearer->media.name or tipc_bclink_name and the hope
that wchat_t will never reach the kernel)

re,
 wh




Florian Westphal wrote:
> From: Florian Westphal <fw@strlen.de>
> 
> convert sprintf(a,b) to strcpy(a,b). Make tipc_bclink_name[] const.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> 
> ---
> 
> compile tested; diffed against davem/net-2.6.
> 
> --- a/net/tipc/bcast.c
> +++ b/net/tipc/bcast.c
> @@ -119,7 +119,7 @@ static struct bclink *bclink = NULL;
>  static struct link *bcl = NULL;
>  static DEFINE_SPINLOCK(bc_lock);
>  
> -char tipc_bclink_name[] = "multicast-link";
> +const char tipc_bclink_name[] = "multicast-link";
>  
>  
>  static u32 buf_seqno(struct sk_buff *buf)
> @@ -790,7 +790,7 @@ int tipc_bclink_init(void)
>  	INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
>  	bcbearer->bearer.media = &bcbearer->media;
>  	bcbearer->media.send_msg = tipc_bcbearer_send;
> -	sprintf(bcbearer->media.name, "tipc-multicast");
> +	strcpy(bcbearer->media.name, "tipc-multicast");
>  
>  	bcl = &bclink->link;
>  	memset(bclink, 0, sizeof(struct bclink));
> @@ -802,7 +802,7 @@ int tipc_bclink_init(void)
>  	tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
>  	bcl->b_ptr = &bcbearer->bearer;
>  	bcl->state = WORKING_WORKING;
> -	sprintf(bcl->name, tipc_bclink_name);
> +	strcpy(bcl->name, tipc_bclink_name);
>  
>  	if (BCLINK_LOG_BUF_SIZE) {
>  		char *pb = kmalloc(BCLINK_LOG_BUF_SIZE, GFP_ATOMIC);
> diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
> --- a/net/tipc/bcast.h
> +++ b/net/tipc/bcast.h
> @@ -70,7 +70,7 @@ struct port_list {
>  
>  struct node;
>  
> -extern char tipc_bclink_name[];
> +extern const char tipc_bclink_name[];
>  
>  
>  /**
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -667,7 +667,7 @@ struct sk_buff *tipc_node_get_links(cons
>          link_info.dest = tipc_own_addr & 0xfffff00;
>  	link_info.dest = htonl(link_info.dest);
>          link_info.up = htonl(1);
> -        sprintf(link_info.str, tipc_bclink_name);
> +        strcpy(link_info.str, tipc_bclink_name);
>  	tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
>  
>  	/* Add TLVs for any other links in scope */
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
> 
> 
> 
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: kernel-janitors@lists.osdl.org,
	tipc-discussion@lists.sourceforge.net, netdev@vger.kernel.org
Subject: Re: [KJ] [patch] net/tipc: sprintf/strcpy conversion
Date: Wed, 01 Nov 2006 22:38:26 +0100	[thread overview]
Message-ID: <454913D2.9050608@bfs.de> (raw)
In-Reply-To: <20061101140624.GA7694@Chamillionaire.breakpoint.cc>


hi Florian,

These line
+	strcpy(bcbearer->media.name, "tipc-multicast");

i gues that means tipc_bclink_name ?
an even more secure version could be like this:

	strncpy(bcbearer->media.name,sizeof(bcbearer->media.name),tipc_bclink_name);

(in case someone ever changes the size of cbearer->media.name or tipc_bclink_name and the hope
that wchat_t will never reach the kernel)

re,
 wh




Florian Westphal wrote:
> From: Florian Westphal <fw@strlen.de>
> 
> convert sprintf(a,b) to strcpy(a,b). Make tipc_bclink_name[] const.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> 
> ---
> 
> compile tested; diffed against davem/net-2.6.
> 
> --- a/net/tipc/bcast.c
> +++ b/net/tipc/bcast.c
> @@ -119,7 +119,7 @@ static struct bclink *bclink = NULL;
>  static struct link *bcl = NULL;
>  static DEFINE_SPINLOCK(bc_lock);
>  
> -char tipc_bclink_name[] = "multicast-link";
> +const char tipc_bclink_name[] = "multicast-link";
>  
>  
>  static u32 buf_seqno(struct sk_buff *buf)
> @@ -790,7 +790,7 @@ int tipc_bclink_init(void)
>  	INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
>  	bcbearer->bearer.media = &bcbearer->media;
>  	bcbearer->media.send_msg = tipc_bcbearer_send;
> -	sprintf(bcbearer->media.name, "tipc-multicast");
> +	strcpy(bcbearer->media.name, "tipc-multicast");
>  
>  	bcl = &bclink->link;
>  	memset(bclink, 0, sizeof(struct bclink));
> @@ -802,7 +802,7 @@ int tipc_bclink_init(void)
>  	tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
>  	bcl->b_ptr = &bcbearer->bearer;
>  	bcl->state = WORKING_WORKING;
> -	sprintf(bcl->name, tipc_bclink_name);
> +	strcpy(bcl->name, tipc_bclink_name);
>  
>  	if (BCLINK_LOG_BUF_SIZE) {
>  		char *pb = kmalloc(BCLINK_LOG_BUF_SIZE, GFP_ATOMIC);
> diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
> --- a/net/tipc/bcast.h
> +++ b/net/tipc/bcast.h
> @@ -70,7 +70,7 @@ struct port_list {
>  
>  struct node;
>  
> -extern char tipc_bclink_name[];
> +extern const char tipc_bclink_name[];
>  
>  
>  /**
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -667,7 +667,7 @@ struct sk_buff *tipc_node_get_links(cons
>          link_info.dest = tipc_own_addr & 0xfffff00;
>  	link_info.dest = htonl(link_info.dest);
>          link_info.up = htonl(1);
> -        sprintf(link_info.str, tipc_bclink_name);
> +        strcpy(link_info.str, tipc_bclink_name);
>  	tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
>  
>  	/* Add TLVs for any other links in scope */
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
> 
> 
> 

  reply	other threads:[~2006-11-01 21:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-01 14:06 [KJ] [patch] net/tipc: sprintf/strcpy conversion Florian Westphal
2006-11-01 14:06 ` Florian Westphal
2006-11-01 21:38 ` walter harms [this message]
2006-11-01 21:38   ` [KJ] " walter harms
2006-11-01 23:19   ` David Miller
2006-11-01 23:19     ` David Miller
2006-11-02  7:45     ` walter harms
2006-11-02  7:45       ` walter harms
2006-11-02  6:26   ` [KJ] [tipc-discussion] [patch] net/tipc: sprintf/strcpy Florian Westphal
2006-11-02  6:26     ` [tipc-discussion] [KJ] [patch] net/tipc: sprintf/strcpy conversion Florian Westphal
2006-11-02  7:57     ` [KJ] [tipc-discussion] [patch] net/tipc: walter harms
2006-11-02  7:57       ` [KJ] [tipc-discussion] [patch] net/tipc: sprintf/strcpy conversion walter harms
2006-11-16  7:28     ` [KJ] [tipc-discussion] [patch] net/tipc:sprintf/strcpy Randy Dunlap
2006-11-03  0:09 ` [KJ] [patch] net/tipc: sprintf/strcpy conversion Alexey Dobriyan
2006-11-03  0:09   ` Alexey Dobriyan
2006-11-03 10:50   ` Hagen Paul Pfeifer
2006-11-03 10:50     ` Hagen Paul Pfeifer

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=454913D2.9050608@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    /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.