public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored.
@ 2011-11-14 15:03 Steve Dickson
  2011-11-14 17:44 ` Jim Rees
  2011-11-14 21:11 ` Steve Dickson
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Dickson @ 2011-11-14 15:03 UTC (permalink / raw)
  To: Linux NFS Mailing List

In the parsing routine, conf_parse_line(), a string
is not being null terminated which is causing
section of the config file to be ignored.

https://bugzilla.linux-nfs.org/show_bug.cgi?id=205

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 support/nfs/conffile.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index fa0dc6b..3990578 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -256,13 +256,14 @@ conf_parse_line(int trans, char *line, size_t sz)
 			val++, j++;
 		if (*val)
 			i = j;
-		section = malloc(i);
+		section = malloc(i+1);
 		if (!section) {
 			xlog_warn("conf_parse_line: %d: malloc (%lu) failed", ln,
 						(unsigned long)i);
 			return;
 		}
 		strncpy(section, line, i);
+		section[i] = '\0';
 
 		if (arg) 
 			free(arg);
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored.
  2011-11-14 15:03 [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored Steve Dickson
@ 2011-11-14 17:44 ` Jim Rees
  2011-11-14 18:02   ` Steve Dickson
  2011-11-14 21:11 ` Steve Dickson
  1 sibling, 1 reply; 4+ messages in thread
From: Jim Rees @ 2011-11-14 17:44 UTC (permalink / raw)
  To: Steve Dickson; +Cc: Linux NFS Mailing List

Steve Dickson wrote:

  In the parsing routine, conf_parse_line(), a string
  is not being null terminated which is causing
  section of the config file to be ignored.
  
  https://bugzilla.linux-nfs.org/show_bug.cgi?id=205
  
  Signed-off-by: Steve Dickson <steved@redhat.com>
  ---
   support/nfs/conffile.c |    3 ++-
   1 files changed, 2 insertions(+), 1 deletions(-)
  
  diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
  index fa0dc6b..3990578 100644
  --- a/support/nfs/conffile.c
  +++ b/support/nfs/conffile.c
  @@ -256,13 +256,14 @@ conf_parse_line(int trans, char *line, size_t sz)
   			val++, j++;
   		if (*val)
   			i = j;
  -		section = malloc(i);
  +		section = malloc(i+1);
   		if (!section) {
   			xlog_warn("conf_parse_line: %d: malloc (%lu) failed", ln,
   						(unsigned long)i);
   			return;
   		}
   		strncpy(section, line, i);
  +		section[i] = '\0';
   
   		if (arg) 
   			free(arg);

Use of strdup() would not only make the code simpler but would eliminate the
possibility of introducing this kind of bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored.
  2011-11-14 17:44 ` Jim Rees
@ 2011-11-14 18:02   ` Steve Dickson
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2011-11-14 18:02 UTC (permalink / raw)
  To: Jim Rees; +Cc: Linux NFS Mailing List



On 11/14/2011 12:44 PM, Jim Rees wrote:
> Steve Dickson wrote:
> 
>   In the parsing routine, conf_parse_line(), a string
>   is not being null terminated which is causing
>   section of the config file to be ignored.
>   
>   https://bugzilla.linux-nfs.org/show_bug.cgi?id=205
>   
>   Signed-off-by: Steve Dickson <steved@redhat.com>
>   ---
>    support/nfs/conffile.c |    3 ++-
>    1 files changed, 2 insertions(+), 1 deletions(-)
>   
>   diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
>   index fa0dc6b..3990578 100644
>   --- a/support/nfs/conffile.c
>   +++ b/support/nfs/conffile.c
>   @@ -256,13 +256,14 @@ conf_parse_line(int trans, char *line, size_t sz)
>    			val++, j++;
>    		if (*val)
>    			i = j;
>   -		section = malloc(i);
>   +		section = malloc(i+1);
>    		if (!section) {
>    			xlog_warn("conf_parse_line: %d: malloc (%lu) failed", ln,
>    						(unsigned long)i);
>    			return;
>    		}
>    		strncpy(section, line, i);
>   +		section[i] = '\0';
>    
>    		if (arg) 
>    			free(arg);
> 
> Use of strdup() would not only make the code simpler but would eliminate the
> possibility of introducing this kind of bug.
I thought of that... but from my reading of the code
the entire string is not wanted, just a section of
the string is needed...  

thanks!

steved.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored.
  2011-11-14 15:03 [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored Steve Dickson
  2011-11-14 17:44 ` Jim Rees
@ 2011-11-14 21:11 ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2011-11-14 21:11 UTC (permalink / raw)
  To: Steve Dickson; +Cc: Linux NFS Mailing List



On 11/14/2011 10:03 AM, Steve Dickson wrote:
> In the parsing routine, conf_parse_line(), a string
> is not being null terminated which is causing
> section of the config file to be ignored.
> 
> https://bugzilla.linux-nfs.org/show_bug.cgi?id=205
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed...

steved.

> ---
>  support/nfs/conffile.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
> index fa0dc6b..3990578 100644
> --- a/support/nfs/conffile.c
> +++ b/support/nfs/conffile.c
> @@ -256,13 +256,14 @@ conf_parse_line(int trans, char *line, size_t sz)
>  			val++, j++;
>  		if (*val)
>  			i = j;
> -		section = malloc(i);
> +		section = malloc(i+1);
>  		if (!section) {
>  			xlog_warn("conf_parse_line: %d: malloc (%lu) failed", ln,
>  						(unsigned long)i);
>  			return;
>  		}
>  		strncpy(section, line, i);
> +		section[i] = '\0';
>  
>  		if (arg) 
>  			free(arg);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-14 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 15:03 [PATCH] rpc.idmapd: Sections in idmapd.conf are ignored Steve Dickson
2011-11-14 17:44 ` Jim Rees
2011-11-14 18:02   ` Steve Dickson
2011-11-14 21:11 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox