All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <lautrbach@redhat.com>
To: Huaxin Lu <luhuaxin1@huawei.com>, selinux@vger.kernel.org
Cc: shenyining@huawei.com, fangxiuning@huawei.com, zhujianwei7@huawei.com
Subject: Re: [PATCH] libselinux: add check for calloc in check_booleans
Date: Fri, 30 Jun 2023 14:29:07 +0200	[thread overview]
Message-ID: <87v8f5yvzg.fsf@redhat.com> (raw)
In-Reply-To: <87sfad0x7o.fsf@redhat.com>

Petr Lautrbach <plautrba@redhat.com> writes:

> Huaxin Lu <luhuaxin1@huawei.com> writes:
>
>> Check the return value of calloc() to avoid null pointer reference.
>>
>> Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
>> ---
>>  libselinux/src/audit2why.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c
>> index ba1a66e..2def89f 100644
>> --- a/libselinux/src/audit2why.c
>> +++ b/libselinux/src/audit2why.c
>> @@ -149,6 +149,12 @@ static int check_booleans(struct boolean_t **bools)
>>  
>>  	if (fcnt > 0) {
>>  		*bools = calloc(sizeof(struct boolean_t), fcnt + 1);
>> +		if (!*bools) {
>> +			PyErr_SetString( PyExc_MemoryError, "Out of memory\n");
>> +			free(foundlist);
>> +			return 0;
>> +		}
>> +	
>
> There's a trailing whitespace, but it's not necessary to resend the patch.
>
> Acked-by: Petr Lautrbach <lautrbach@redhat.com>
>

merged, thanks

>>  		struct boolean_t *b = *bools;
>>  		for (i = 0; i < fcnt; i++) {
>>  			int ctr = foundlist[i];
>> -- 
>> 2.33.0


      reply	other threads:[~2023-06-30 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-18 23:17 [PATCH] libselinux: add check for calloc in check_booleans Huaxin Lu
2023-06-27 14:57 ` Petr Lautrbach
2023-06-30 12:29   ` 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=87v8f5yvzg.fsf@redhat.com \
    --to=lautrbach@redhat.com \
    --cc=fangxiuning@huawei.com \
    --cc=luhuaxin1@huawei.com \
    --cc=selinux@vger.kernel.org \
    --cc=shenyining@huawei.com \
    --cc=zhujianwei7@huawei.com \
    /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.