linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect
@ 2011-07-21 20:35 Malahal Naineni
  2011-07-21 20:35 ` [PATCH 2/2] nfs4-acl-tools: Don't call free_fields when memory isn't allocated Malahal Naineni
  2011-07-26  6:54 ` [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Venkateswararao Jujjuri
  0 siblings, 2 replies; 6+ messages in thread
From: Malahal Naineni @ 2011-07-21 20:35 UTC (permalink / raw)
  To: linux-nfs; +Cc: Malahal Naineni

The sizeof operator, when applied to a parameter declared to have array,
yields the size of the adjusted (pointer) type, even if the parameter
declaration specifies a length.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
---
 libnfs4acl/nfs4_ace_from_string.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libnfs4acl/nfs4_ace_from_string.c b/libnfs4acl/nfs4_ace_from_string.c
index 9d877fb..462fcc0 100644
--- a/libnfs4acl/nfs4_ace_from_string.c
+++ b/libnfs4acl/nfs4_ace_from_string.c
@@ -100,7 +100,7 @@ parse_alloc_fields(char *buf, char *fields[NUMFIELDS])
 	if (!buf)
 		return -EINVAL;
 
-	memset(fields, 0, sizeof(fields));
+	memset(fields, 0, sizeof(char *) * NUMFIELDS);
 
 	for (i = 0; buf[i] != '\0'; i++) {
 		if (buf[i] == ':')
-- 
1.7.4.4


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

* [PATCH 2/2] nfs4-acl-tools: Don't call free_fields when memory isn't allocated.
  2011-07-21 20:35 [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Malahal Naineni
@ 2011-07-21 20:35 ` Malahal Naineni
  2011-07-26  6:54 ` [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Venkateswararao Jujjuri
  1 sibling, 0 replies; 6+ messages in thread
From: Malahal Naineni @ 2011-07-21 20:35 UTC (permalink / raw)
  To: linux-nfs; +Cc: Malahal Naineni


Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
---
 libnfs4acl/nfs4_ace_from_string.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libnfs4acl/nfs4_ace_from_string.c b/libnfs4acl/nfs4_ace_from_string.c
index 462fcc0..510ffee 100644
--- a/libnfs4acl/nfs4_ace_from_string.c
+++ b/libnfs4acl/nfs4_ace_from_string.c
@@ -150,7 +150,7 @@ struct nfs4_ace * nfs4_ace_from_string(char *ace_buf, int is_dir)
 	/* parse_alloc_fields had split up ace_buf so now we copy it to bufp */
 	bufp = malloc(strlen(ace_buf) + 1);
 	if (!bufp)
-		goto out_free;
+		goto out;
 	strcpy(bufp,ace_buf);
 
 	ret = parse_alloc_fields(bufp, fields);
-- 
1.7.4.4


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

* Re: [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect
  2011-07-21 20:35 [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Malahal Naineni
  2011-07-21 20:35 ` [PATCH 2/2] nfs4-acl-tools: Don't call free_fields when memory isn't allocated Malahal Naineni
@ 2011-07-26  6:54 ` Venkateswararao Jujjuri
  2011-07-26 17:58   ` Malahal Naineni
  1 sibling, 1 reply; 6+ messages in thread
From: Venkateswararao Jujjuri @ 2011-07-26  6:54 UTC (permalink / raw)
  To: Malahal Naineni; +Cc: public-linux-nfs-u79uwXL29TY76Z2rM5mHXA




On 07/21/2011 01:35 PM, Malahal Naineni wrote:
> The sizeof operator, when applied to a parameter declared to have array,
> yields the size of the adjusted (pointer) type, even if the parameter
> declaration specifies a length.
>
> Signed-off-by: Malahal Naineni<malahal-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>   libnfs4acl/nfs4_ace_from_string.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libnfs4acl/nfs4_ace_from_string.c b/libnfs4acl/nfs4_ace_from_string.c
> index 9d877fb..462fcc0 100644
> --- a/libnfs4acl/nfs4_ace_from_string.c
> +++ b/libnfs4acl/nfs4_ace_from_string.c
> @@ -100,7 +100,7 @@ parse_alloc_fields(char *buf, char *fields[NUMFIELDS])
>   	if (!buf)
>   		return -EINVAL;
>
> -	memset(fields, 0, sizeof(fields));
> +	memset(fields, 0, sizeof(char *) * NUMFIELDS);
>
>   	for (i = 0; buf[i] != '\0'; i++) {
>   		if (buf[i] == ':')

Could it be compiler specific? It is working fine for me


Test]$ cat sizeof.c
===========
#include <stdio.h>
#define NUMFIELDS 10
main()
{
	char *fields1[NUMFIELDS];
	char fields2[NUMFIELDS];

	printf("sizeof(fields1):%d sizeof(char *)*NUMFIELDS:%d\n", 
sizeof(fields1), sizeof(char *)*NUMFIELDS);
	printf("sizeof(fields2):%d sizeof(char)*NUMFIELDS:%d\n", 
sizeof(fields2), sizeof(char)*NUMFIELDS);
}
============

[jvrao Test]$ make sizeof
cc     sizeof.c   -o sizeof
[jvrao Test]$ ./sizeof
sizeof(fields1):80 sizeof(char *)*NUMFIELDS:80
sizeof(fields2):10 sizeof(char)*NUMFIELDS:10


[jvrao Test]$ cc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap 
--enable-shared --enable-threads=posix --enable-checking=release 
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions 
--enable-gnu-unique-object 
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada 
--enable-java-awt=gtk --disable-dssi 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre 
--enable-libgcj-multifile --enable-java-maintainer-mode 
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic 
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)











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

* Re: [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect
  2011-07-26  6:54 ` [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Venkateswararao Jujjuri
@ 2011-07-26 17:58   ` Malahal Naineni
  2011-08-05 20:05     ` J. Bruce Fields
  0 siblings, 1 reply; 6+ messages in thread
From: Malahal Naineni @ 2011-07-26 17:58 UTC (permalink / raw)
  To: linux-nfs

Venkateswararao Jujjuri [jvrao@linux.vnet.ibm.com] wrote:
> 
> On 07/21/2011 01:35 PM, Malahal Naineni wrote:
> >The sizeof operator, when applied to a parameter declared to have array,
> >yields the size of the adjusted (pointer) type, even if the parameter
> >declaration specifies a length.
> >
> >---
> >  libnfs4acl/nfs4_ace_from_string.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> >diff --git a/libnfs4acl/nfs4_ace_from_string.c b/libnfs4acl/nfs4_ace_from_string.c
> >index 9d877fb..462fcc0 100644
> >--- a/libnfs4acl/nfs4_ace_from_string.c
> >+++ b/libnfs4acl/nfs4_ace_from_string.c
> >@@ -100,7 +100,7 @@ parse_alloc_fields(char *buf, char *fields[NUMFIELDS])
> >  	if (!buf)
> >  		return -EINVAL;
> >
> >-	memset(fields, 0, sizeof(fields));
> >+	memset(fields, 0, sizeof(char *) * NUMFIELDS);
> >
> >  	for (i = 0; buf[i] != '\0'; i++) {
> >  		if (buf[i] == ':')
> 
> Could it be compiler specific? It is working fine for me
> 
> 
> Test]$ cat sizeof.c
> ===========
> #include <stdio.h>
> #define NUMFIELDS 10
> main()
> {
> 	char *fields1[NUMFIELDS];
> 	char fields2[NUMFIELDS];
> 
> 	printf("sizeof(fields1):%d sizeof(char *)*NUMFIELDS:%d\n",
> sizeof(fields1), sizeof(char *)*NUMFIELDS);
> 	printf("sizeof(fields2):%d sizeof(char)*NUMFIELDS:%d\n",
> sizeof(fields2), sizeof(char)*NUMFIELDS);
> }

It works as expected in the definition scope. It doesn't work "when
applied to a parameter declared to have array". It looks like, this is
part of the C99 spec, so can't be compiler specific. Try this:

static void fun(char *a[10])
{
 	printf("sizeof returned: %d\n", sizeof(a));
}

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

* Re: [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect
  2011-07-26 17:58   ` Malahal Naineni
@ 2011-08-05 20:05     ` J. Bruce Fields
  2011-08-05 20:50       ` Malahal Naineni
  0 siblings, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2011-08-05 20:05 UTC (permalink / raw)
  To: linux-nfs; +Cc: jvrao

Apologies for the delay; both patches (and some minor git-related
cleanup) applied and pushed out to

	git://linux-nfs.org/~bfields/nfs4-acl-tools.git

--b.

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

* Re: [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect
  2011-08-05 20:05     ` J. Bruce Fields
@ 2011-08-05 20:50       ` Malahal Naineni
  0 siblings, 0 replies; 6+ messages in thread
From: Malahal Naineni @ 2011-08-05 20:50 UTC (permalink / raw)
  To: linux-nfs

J. Bruce Fields [bfields@fieldses.org] wrote:
> Apologies for the delay; both patches (and some minor git-related
> cleanup) applied and pushed out to
> 
> 	git://linux-nfs.org/~bfields/nfs4-acl-tools.git
> 
> --b.

Thank you Bruce!

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

end of thread, other threads:[~2011-08-05 20:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-21 20:35 [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Malahal Naineni
2011-07-21 20:35 ` [PATCH 2/2] nfs4-acl-tools: Don't call free_fields when memory isn't allocated Malahal Naineni
2011-07-26  6:54 ` [PATCH 1/2] nfs4-acl-tools: Fix segfault if format of the input file is incorrect Venkateswararao Jujjuri
2011-07-26 17:58   ` Malahal Naineni
2011-08-05 20:05     ` J. Bruce Fields
2011-08-05 20:50       ` Malahal Naineni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).