All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: James Carter <jwcart2@tycho.nsa.gov>, selinux@tycho.nsa.gov
Subject: Re: [PATCH] libsepol: create new keys with copy of 'name' variable
Date: Tue, 25 Aug 2015 22:27:02 +0200	[thread overview]
Message-ID: <55DCCF96.6010407@redhat.com> (raw)
In-Reply-To: <55DCB385.1090607@tycho.nsa.gov>

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

On 08/25/2015 08:27 PM, James Carter wrote:
> On 08/25/2015 10:05 AM, Petr Lautrbach wrote:
>> --- a/libsepol/src/boolean_record.c
>> +++ b/libsepol/src/boolean_record.c
>> @@ -25,12 +25,14 @@ int sepol_bool_key_create(sepol_handle_t * handle,
>>       sepol_bool_key_t *tmp_key =
>>           (sepol_bool_key_t *) malloc(sizeof(struct sepol_bool_key));
>>
>> -    if (!tmp_key) {
>> +    char *tmp_name = strdup(name);
>> +
>> +    if (!tmp_key || !tmp_name) {
>>           ERR(handle, "out of memory, " "could not create boolean key");
>>           return STATUS_ERR;
>>       }
>>
> 
> Need to free tmp_key if it is allocated, but the strdup for tmp_name
> fails. And vice versa.
> 

The patch is apparently not ready yet. It can't be even compiled, see
bellow. Sorry for the noise.

cc -Werror -Wall -W -Wundef -Wshadow -Wmissing-format-attribute -O2 -I.
-I../include -D_GNU_SOURCE -I../cil/include -fPIC -c -o boolean_record.o
boolean_record.c
boolean_record.c: In function ‘sepol_bool_key_free’:
boolean_record.c:67:7: error: passing argument 1 of ‘free’ discards
‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  free(key->name);
       ^
In file included from boolean_record.c:2:0:
/usr/include/stdlib.h:483:13: note: expected ‘void *’ but argument is of
type ‘const char *’
 extern void free (void *__ptr) __THROW;



-- 
Petr Lautrbach


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2015-08-25 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 14:05 [PATCH] libsepol: create new keys with copy of 'name' variable Petr Lautrbach
2015-08-25 18:27 ` James Carter
2015-08-25 20:27   ` Petr Lautrbach [this message]

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=55DCCF96.6010407@redhat.com \
    --to=plautrba@redhat.com \
    --cc=jwcart2@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.