All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Rees <rees@umich.edu>
To: faizan husain <faizanh@linux.vnet.ibm.com>
Cc: linux-nfs@vger.kernel.org, Frank S Filz <ffilz@us.ibm.com>,
	jvrao@linux.vnet.ibm.com
Subject: Re: [PATCH] nfs4-acl-tools : nfs4_setfacl' failed with unexpected messages if the format of the input file is incorrect.
Date: Thu, 30 Jun 2011 07:51:56 -0400	[thread overview]
Message-ID: <20110630115156.GA2347@merit.edu> (raw)
In-Reply-To: <4E0C1285.1060601@linux.vnet.ibm.com>

faizan husain wrote:

  problem was this part of code in parse_alloc_fields() function:
  if (count != 3)
           goto out_free;
  at this point memory is not allocated for fields leading to double
  free of memory once inside parse_alloc_fields() and again inside
  nfs4_ace_from_string().
  
  instead we can change the  code:
  if (count != 3)
      return -EINVAL; /*Invalid argument*/
  
  This look to me as more foolproof solution.
  what do you say?

That looks correct.  It should return EINVAL here, and there is no need to
free.  But I don't see why it fixes your segfault.  fields[] should be all
NULL at this point, so free_fields shouldn't do anything.

The test in free_fields() is redundant, since free(NULL) doesn't do
anything.  But it could be made more foolproof by zeroing the array so you
can't get a double free:

void
free_fields(char *fields[NUMFIELDS])
{
	int i;

	for (i = 0; i < NUMFIELDS; i++) {
		free(fields[i]);
		fields[i] = NULL;
	}
}

  reply	other threads:[~2011-06-30 11:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29  7:21 [PATCH] nfs4-acl-tools : nfs4_setfacl' failed with unexpected messages if the format of the input file is incorrect faizan husain
2011-06-29 12:18 ` Jim Rees
2011-06-30  6:07   ` faizan husain
2011-06-30 11:51     ` Jim Rees [this message]
2011-06-30 13:33       ` faizan husain

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=20110630115156.GA2347@merit.edu \
    --to=rees@umich.edu \
    --cc=faizanh@linux.vnet.ibm.com \
    --cc=ffilz@us.ibm.com \
    --cc=jvrao@linux.vnet.ibm.com \
    --cc=linux-nfs@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.