[spice-common] test-ssl-verify: test_generic: initialize num_entries

Submitted by Uri Lublin on Sept. 1, 2019, 1:50 p.m.

Details

Message ID 20190901135012.2035-1-uril@redhat.com
State New
Headers show
Series "test-ssl-verify: test_generic: initialize num_entries" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Uri Lublin Sept. 1, 2019, 1:50 p.m.
If name is null num_entries may hold garbage value

clang warning: Assigned value is garbage or undefined
   g_assert_cmpint(num_entries, ==, entry_count);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also check name before num_entries.

Signed-off-by: Uri Lublin <uril@redhat.com>
---
 tests/test-ssl-verify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/tests/test-ssl-verify.c b/tests/test-ssl-verify.c
index f5c5881..f80eb4c 100644
--- a/tests/test-ssl-verify.c
+++ b/tests/test-ssl-verify.c
@@ -79,7 +79,7 @@  static void test_generic(const void *arg)
 {
     const TestGenericParams *params = arg;
     X509_NAME *name;
-    int num_entries;
+    int num_entries = -1;
 
     setup_results(params->output);
     name = subject_to_x509_name(params->input, &num_entries);

Comments

> 
> If name is null num_entries may hold garbage value
> 
> clang warning: Assigned value is garbage or undefined
>    g_assert_cmpint(num_entries, ==, entry_count);
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Also check name before num_entries.
> 

Why this last sentence?

> Signed-off-by: Uri Lublin <uril@redhat.com>
> ---
>  tests/test-ssl-verify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/test-ssl-verify.c b/tests/test-ssl-verify.c
> index f5c5881..f80eb4c 100644
> --- a/tests/test-ssl-verify.c
> +++ b/tests/test-ssl-verify.c
> @@ -79,7 +79,7 @@ static void test_generic(const void *arg)
>  {
>      const TestGenericParams *params = arg;
>      X509_NAME *name;
> -    int num_entries;
> +    int num_entries = -1;
>  
>      setup_results(params->output);
>      name = subject_to_x509_name(params->input, &num_entries);

Otherwise patch is fine.

Frediano
On 9/1/19 7:20 PM, Frediano Ziglio wrote:
>>
>> If name is null num_entries may hold garbage value
>>
>> clang warning: Assigned value is garbage or undefined
>>     g_assert_cmpint(num_entries, ==, entry_count);
>>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Also check name before num_entries.
>>
> 
> Why this last sentence?

oops, the first patch I wrote (and did not send) also
checked name before (switched the order of the two check lines).
Since it does not really matter, I removed it.

I'll delete this from the commit log.

Thanks,
     Uri.

> 
>> Signed-off-by: Uri Lublin <uril@redhat.com>
>> ---
>>   tests/test-ssl-verify.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/test-ssl-verify.c b/tests/test-ssl-verify.c
>> index f5c5881..f80eb4c 100644
>> --- a/tests/test-ssl-verify.c
>> +++ b/tests/test-ssl-verify.c
>> @@ -79,7 +79,7 @@ static void test_generic(const void *arg)
>>   {
>>       const TestGenericParams *params = arg;
>>       X509_NAME *name;
>> -    int num_entries;
>> +    int num_entries = -1;
>>   
>>       setup_results(params->output);
>>       name = subject_to_x509_name(params->input, &num_entries);
> 
> Otherwise patch is fine.
> 
> Frediano
>