* [PATCH 1/1] libsemanage: always check append_arg return value
@ 2018-04-22 19:30 Nicolas Iooss
2018-04-23 16:50 ` William Roberts
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Iooss @ 2018-04-22 19:30 UTC (permalink / raw)
To: selinux
When split_args() calls append_arg(), the returned value needs to be
checked in order to detect memory allocation failure. Checks were
missing in two places, which are spotted by clang's static analyzer:
semanage_store.c:1352:7: warning: Value stored to 'rc' is never
read
rc = append_arg(&argv, &num_args, arg);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semanage_store.c:1368:3: warning: Value stored to 'rc' is never read
rc = append_arg(&argv, &num_args, arg);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
libsemanage/src/semanage_store.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index 14ad99c152ad..bce648c46464 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -1350,6 +1350,8 @@ static char **split_args(const char *arg0, char *arg_string,
if (isspace(*s) && !in_quote && !in_dquote) {
if (arg != NULL) {
rc = append_arg(&argv, &num_args, arg);
+ if (rc)
+ goto cleanup;
free(arg);
arg = NULL;
}
@@ -1366,6 +1368,8 @@ static char **split_args(const char *arg0, char *arg_string,
}
if (arg != NULL) {
rc = append_arg(&argv, &num_args, arg);
+ if (rc)
+ goto cleanup;
free(arg);
arg = NULL;
}
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] libsemanage: always check append_arg return value
2018-04-22 19:30 [PATCH 1/1] libsemanage: always check append_arg return value Nicolas Iooss
@ 2018-04-23 16:50 ` William Roberts
2018-04-25 17:09 ` William Roberts
0 siblings, 1 reply; 3+ messages in thread
From: William Roberts @ 2018-04-23 16:50 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: selinux
On Sun, Apr 22, 2018 at 12:30 PM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
> When split_args() calls append_arg(), the returned value needs to be
> checked in order to detect memory allocation failure. Checks were
> missing in two places, which are spotted by clang's static analyzer:
>
> semanage_store.c:1352:7: warning: Value stored to 'rc' is never
> read
> rc = append_arg(&argv, &num_args, arg);
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> semanage_store.c:1368:3: warning: Value stored to 'rc' is never read
> rc = append_arg(&argv, &num_args, arg);
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
> libsemanage/src/semanage_store.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
> index 14ad99c152ad..bce648c46464 100644
> --- a/libsemanage/src/semanage_store.c
> +++ b/libsemanage/src/semanage_store.c
> @@ -1350,6 +1350,8 @@ static char **split_args(const char *arg0, char *arg_string,
> if (isspace(*s) && !in_quote && !in_dquote) {
> if (arg != NULL) {
> rc = append_arg(&argv, &num_args, arg);
> + if (rc)
> + goto cleanup;
> free(arg);
> arg = NULL;
> }
> @@ -1366,6 +1368,8 @@ static char **split_args(const char *arg0, char *arg_string,
> }
> if (arg != NULL) {
> rc = append_arg(&argv, &num_args, arg);
> + if (rc)
> + goto cleanup;
> free(arg);
> arg = NULL;
> }
> --
> 2.17.0
>
>
ack
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] libsemanage: always check append_arg return value
2018-04-23 16:50 ` William Roberts
@ 2018-04-25 17:09 ` William Roberts
0 siblings, 0 replies; 3+ messages in thread
From: William Roberts @ 2018-04-25 17:09 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: selinux
Merged: https://github.com/SELinuxProject/selinux/pull/94
On Mon, Apr 23, 2018 at 9:50 AM, William Roberts
<bill.c.roberts@gmail.com> wrote:
> On Sun, Apr 22, 2018 at 12:30 PM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>> When split_args() calls append_arg(), the returned value needs to be
>> checked in order to detect memory allocation failure. Checks were
>> missing in two places, which are spotted by clang's static analyzer:
>>
>> semanage_store.c:1352:7: warning: Value stored to 'rc' is never
>> read
>> rc = append_arg(&argv, &num_args, arg);
>> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> semanage_store.c:1368:3: warning: Value stored to 'rc' is never read
>> rc = append_arg(&argv, &num_args, arg);
>> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>> ---
>> libsemanage/src/semanage_store.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
>> index 14ad99c152ad..bce648c46464 100644
>> --- a/libsemanage/src/semanage_store.c
>> +++ b/libsemanage/src/semanage_store.c
>> @@ -1350,6 +1350,8 @@ static char **split_args(const char *arg0, char *arg_string,
>> if (isspace(*s) && !in_quote && !in_dquote) {
>> if (arg != NULL) {
>> rc = append_arg(&argv, &num_args, arg);
>> + if (rc)
>> + goto cleanup;
>> free(arg);
>> arg = NULL;
>> }
>> @@ -1366,6 +1368,8 @@ static char **split_args(const char *arg0, char *arg_string,
>> }
>> if (arg != NULL) {
>> rc = append_arg(&argv, &num_args, arg);
>> + if (rc)
>> + goto cleanup;
>> free(arg);
>> arg = NULL;
>> }
>> --
>> 2.17.0
>>
>>
>
> ack
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-25 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-22 19:30 [PATCH 1/1] libsemanage: always check append_arg return value Nicolas Iooss
2018-04-23 16:50 ` William Roberts
2018-04-25 17:09 ` William Roberts
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.