All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Alice Chu <alice.chu@sta.samsung.com>
Cc: "selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>,
	"seandroid-list@tycho.nsa.gov" <seandroid-list@tycho.nsa.gov>
Subject: Re: Fixing external/libsepol issues found by Klocwork
Date: Tue, 08 Jan 2013 10:14:42 -0500	[thread overview]
Message-ID: <50EC37E2.2000705@tycho.nsa.gov> (raw)
In-Reply-To: <C1432A7484D61749AF22A060C2B03C5D1632046A1B@StaEx7mb3.telecom.sna.samsung.com>

On 01/07/2013 08:51 PM, Alice Chu wrote:
> Hello,
>
> Attached you will find the Klocwork report on seandroid master branch external/libsepol. The following is the fix.
> Please review and give me your feedback.
>
> Thank you very much,
> Alice Chu
> ======================================================================================
>>From 1b6465ee62e9d5f1b5c7ef5c69b97bc572472f78 Mon Sep 17 00:00:00 2001
> From: Alice Chu <alice.chu@sta.samsung.com>
> Date: Fri, 4 Jan 2013 15:51:37 -0800
> Subject: [PATCH] Fix issues found by Klocwork
>
> Change-Id: I055d851c95de6326a6833b02a40261f282847c7b
> ---
>   include/sepol/policydb/symtab.h |    1 +
>   src/expand.c                    |   13 +++++++++++++
>   src/genusers.c                  |   11 ++++++++++-
>   src/hierarchy.c                 |    1 +
>   src/link.c                      |    7 ++++++-
>   src/policydb.c                  |    6 ++++--
>   src/policydb_convert.c          |    1 +
>   src/services.c                  |    2 ++
>   src/symtab.c                    |    9 +++++++++
>   src/write.c                     |    1 +
>   10 files changed, 48 insertions(+), 4 deletions(-)
>

> diff --git a/src/symtab.c b/src/symtab.c
> index b3a7aa8..87046b2 100644
> --- a/src/symtab.c
> +++ b/src/symtab.c
> @@ -46,4 +46,13 @@ int symtab_init(symtab_t * s, unsigned int size)
>   	return 0;
>   }
>
> +void symtab_destroy(symtab_t * s)
> +{
> +	if (!s)
> +		return;
> +	if (s->table)
> +		hashtab_destroy(s->table);
> +	free(s);
> +	return;
> +}
>   /* FLASK */

symtab_init() does not allocate s, so symtab_destroy() should not free 
it.  It isn't separately allocated from the containing structure.  Also, 
if you truly want to fully free the symtab, you'll need to pass in a 
destroy function to symtab_destroy and invoke hashtab_map() on the table 
with that destroy function - see for example symtabs_destroy(), 
class_destroy(), etc in policydb.c.



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2013-01-08 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08  1:51 Fixing external/libsepol issues found by Klocwork Alice Chu
2013-01-08 15:14 ` Stephen Smalley [this message]
2013-01-10  2:41   ` Alice Chu
2013-02-01 20:59     ` Eric Paris

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=50EC37E2.2000705@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=alice.chu@sta.samsung.com \
    --cc=seandroid-list@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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.