All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] simutil: Fill unused part of AID with FFs
@ 2021-04-29 16:09 Slava Monich
  2021-04-30 14:54 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Slava Monich @ 2021-04-29 16:09 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

Correct handling of short AIDs will take more than that, but
leaving part of the array uninitialized is wrong in any case.
---
 src/simutil.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/simutil.c b/src/simutil.c
index 5d2aa6a2..e648c918 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -1588,6 +1588,7 @@ GSList *sim_parse_app_template_entries(const unsigned char *buffer, int len)
 			goto error;
 
 		memcpy(app.aid, aid, app.aid_len);
+		memset(app.aid + app.aid_len, 0xff, 16 - app.aid_len);
 
 		app.type = (app.aid[5] << 8) | app.aid[6];
 
-- 
2.25.1

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

* Re: [PATCH] simutil: Fill unused part of AID with FFs
  2021-04-29 16:09 [PATCH] simutil: Fill unused part of AID with FFs Slava Monich
@ 2021-04-30 14:54 ` Denis Kenzior
  2021-05-01 22:39   ` Slava Monich
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2021-04-30 14:54 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Hi Slava,

On 4/29/21 11:09 AM, Slava Monich wrote:
> Correct handling of short AIDs will take more than that, but
> leaving part of the array uninitialized is wrong in any case.
> ---
>   src/simutil.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/simutil.c b/src/simutil.c
> index 5d2aa6a2..e648c918 100644
> --- a/src/simutil.c
> +++ b/src/simutil.c
> @@ -1588,6 +1588,7 @@ GSList *sim_parse_app_template_entries(const unsigned char *buffer, int len)
>   			goto error;
>   
>   		memcpy(app.aid, aid, app.aid_len);
> +		memset(app.aid + app.aid_len, 0xff, 16 - app.aid_len);

Would it not be easier to fix sim-auth to take aid_len into account instead of 
hard-coding 16?  It seems like sim_auth_register is the only one affected, but I 
didn't look deeply.

>   
>   		app.type = (app.aid[5] << 8) | app.aid[6];
>   
> 

Regards,
-Denis

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

* Re: [PATCH] simutil: Fill unused part of AID with FFs
  2021-04-30 14:54 ` Denis Kenzior
@ 2021-05-01 22:39   ` Slava Monich
  0 siblings, 0 replies; 3+ messages in thread
From: Slava Monich @ 2021-05-01 22:39 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]

On 30.4.2021 17.54, Denis Kenzior wrote:
> Hi Slava,
>
> On 4/29/21 11:09 AM, Slava Monich wrote:
>> Correct handling of short AIDs will take more than that, but
>> leaving part of the array uninitialized is wrong in any case.
>> ---
>>   src/simutil.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/src/simutil.c b/src/simutil.c
>> index 5d2aa6a2..e648c918 100644
>> --- a/src/simutil.c
>> +++ b/src/simutil.c
>> @@ -1588,6 +1588,7 @@ GSList *sim_parse_app_template_entries(const 
>> unsigned char *buffer, int len)
>>               goto error;
>>             memcpy(app.aid, aid, app.aid_len);
>> +        memset(app.aid + app.aid_len, 0xff, 16 - app.aid_len);
>
> Would it not be easier to fix sim-auth to take aid_len into account 
> instead of hard-coding 16?  It seems like sim_auth_register is the 
> only one affected, but I didn't look deeply.


AFAICT it's not that trivial but feel free to disregard this patch - it 
doesn't make much sense to fix it half-way.


Rebards,

-Slava

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

end of thread, other threads:[~2021-05-01 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 16:09 [PATCH] simutil: Fill unused part of AID with FFs Slava Monich
2021-04-30 14:54 ` Denis Kenzior
2021-05-01 22:39   ` Slava Monich

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.