Re: [PATCH] libsepol: create new keys with copy of 'name' variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.

[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux