public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] handshake: don't print NULL pmksa pointer
@ 2025-01-06 13:46 James Prestwood
  2025-01-06 15:14 ` Denis Kenzior
  0 siblings, 1 reply; 4+ messages in thread
From: James Prestwood @ 2025-01-06 13:46 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

This is undefined behavior so if no pmksa is found don't print.
---
 src/handshake.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/handshake.c b/src/handshake.c
index f73f91d1..bee76b26 100644
--- a/src/handshake.c
+++ b/src/handshake.c
@@ -1272,11 +1272,11 @@ void handshake_state_cache_pmksa(struct handshake_state *s)
 {
 	struct pmksa *pmksa = handshake_state_steal_pmksa(s);
 
-	l_debug("%p", pmksa);
-
 	if (!pmksa)
 		return;
 
+	l_debug("%p", pmksa);
+
 	if (L_WARN_ON(pmksa_cache_put(pmksa) < 0))
 		l_free(pmksa);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] handshake: don't print NULL pmksa pointer
  2025-01-06 13:46 [PATCH] handshake: don't print NULL pmksa pointer James Prestwood
@ 2025-01-06 15:14 ` Denis Kenzior
  2025-01-06 15:26   ` James Prestwood
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Kenzior @ 2025-01-06 15:14 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 1/6/25 7:46 AM, James Prestwood wrote:
> This is undefined behavior so if no pmksa is found don't print.
> ---
>   src/handshake.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/handshake.c b/src/handshake.c
> index f73f91d1..bee76b26 100644
> --- a/src/handshake.c
> +++ b/src/handshake.c
> @@ -1272,11 +1272,11 @@ void handshake_state_cache_pmksa(struct handshake_state *s)
>   {
>   	struct pmksa *pmksa = handshake_state_steal_pmksa(s);
>   
> -	l_debug("%p", pmksa);
> -

Why is this behavior undefined? Would it not just print 0x0000...?

>   	if (!pmksa)
>   		return;
>   
> +	l_debug("%p", pmksa);
> +
>   	if (L_WARN_ON(pmksa_cache_put(pmksa) < 0))
>   		l_free(pmksa);
>   }

Regards,
-Denis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] handshake: don't print NULL pmksa pointer
  2025-01-06 15:14 ` Denis Kenzior
@ 2025-01-06 15:26   ` James Prestwood
  2025-01-06 15:27     ` Denis Kenzior
  0 siblings, 1 reply; 4+ messages in thread
From: James Prestwood @ 2025-01-06 15:26 UTC (permalink / raw)
  To: Denis Kenzior, iwd

Hi Denis,

On 1/6/25 7:14 AM, Denis Kenzior wrote:
> Hi James,
>
> On 1/6/25 7:46 AM, James Prestwood wrote:
>> This is undefined behavior so if no pmksa is found don't print.
>> ---
>>   src/handshake.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/handshake.c b/src/handshake.c
>> index f73f91d1..bee76b26 100644
>> --- a/src/handshake.c
>> +++ b/src/handshake.c
>> @@ -1272,11 +1272,11 @@ void handshake_state_cache_pmksa(struct 
>> handshake_state *s)
>>   {
>>       struct pmksa *pmksa = handshake_state_steal_pmksa(s);
>>   -    l_debug("%p", pmksa);
>> -
>
> Why is this behavior undefined? Would it not just print 0x0000...?

I had a brain fart, I was thinking for some reason it was using %s not 
%p. So yes, this is a valid input to the %p formatter.

I can alter the commit description, but I do think it still makes sense 
to move the print, or at least modify it to make it clear no PMKSA was 
cached, rather than just printing "nul" or "nil" or "0x0000".

>
>>       if (!pmksa)
>>           return;
>>   +    l_debug("%p", pmksa);
>> +
>>       if (L_WARN_ON(pmksa_cache_put(pmksa) < 0))
>>           l_free(pmksa);
>>   }
>
> Regards,
> -Denis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] handshake: don't print NULL pmksa pointer
  2025-01-06 15:26   ` James Prestwood
@ 2025-01-06 15:27     ` Denis Kenzior
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2025-01-06 15:27 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

 >>
>> Why is this behavior undefined? Would it not just print 0x0000...?
> 
> I had a brain fart, I was thinking for some reason it was using %s not %p. So 
> yes, this is a valid input to the %p formatter.
> 
> I can alter the commit description, but I do think it still makes sense to move 
> the print, or at least modify it to make it clear no PMKSA was cached, rather 
> than just printing "nul" or "nil" or "0x0000".

Sure, that makes sense.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-06 15:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 13:46 [PATCH] handshake: don't print NULL pmksa pointer James Prestwood
2025-01-06 15:14 ` Denis Kenzior
2025-01-06 15:26   ` James Prestwood
2025-01-06 15:27     ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox