hwsim: check if radio name was already set
James Prestwood
PATCH 1/3 hwsim: check if radio name was already set
This was caught by static analysis and shouldn't ever happen.
--- tools/hwsim.c | 3 +++ 1 file changed, 3 insertions(+)
tools/hwsim.c +3 -0
@@ -639,6 +639,9 @@ static void get_radio_callback(struct l_genl_msg *msg, void *user_data)break ;case HWSIM_ATTR_RADIO_NAME : +if (name) +return ; + name =l_strndup (data, len);break ; }
Signature · 1 line
2.34.1
James Prestwood
PATCH 2/3 main: remove unneeded stat call
Static analysis flagged that 'path' was never being checked (which should not ever be NULL) but during that review I noticed stat() was being called, then fstat afterwards.
--- src/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
src/main.c +1 -4
@@ -428,11 +428,8 @@ static bool setup_system_key(void) } path =l_strdup_printf ("%s/%s" , cred_dir, key_id); - -if (stat (path, &st) <0 ) { -l_warn ("SystemdEncrypt: Could not stat %s" , path); +if (!path)return false; - } fd =open (path,O_RDONLY ,0 );if (fd <0 ) {
Signature · 1 line
2.34.1
Denis Kenzior
AppliedRe: [PATCH 2/3] main: remove unneeded stat call
Hi James,
Quoted 12 lines · James Prestwood
Static analysis flagged that 'path' was never being checked (which should not ever be NULL) but during that review I noticed
stat()was being called, then fstat afterwards.--- src/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)src/main.c +0
-0
src/main.c static bool setup_system_key(void) · line 432
Quoted 8 lines
src/main.c +1
-3@@ -428,11 +428,8 @@ static bool setup_system_key(void) } path =l_strdup_printf ("%s/%s" , cred_dir, key_id); - -if (stat (path, &st) <0 ) { -l_warn ("SystemdEncrypt: Could not stat %s" , path); +if (!path)return false;
l_strdup_printf doesn't fail, so I removed this if as well.
src/main.c static bool setup_system_key(void) · line 435
Quoted 5 lines
src/main.c +0
-1- } fd =open (path,O_RDONLY ,0 );if (fd <0 ) {
Applied, thanks.
Regards,
-Denis
James Prestwood
PATCH 3/3 dpp: check return of aes_siv_encrypt
In reply to James PrestwoodThis was caught by static analysis. As is common this should never happen in the real world since the only way this can fail (apart from extreme circumstances like OOM) is if the key size is incorrect, which it will never be.
--- src/dpp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
src/dpp.c +5 -2
@@ -1070,8 +1070,11 @@ static void send_authenticate_response(struct dpp_sm *dpp)* do not use AAD; in other words, the number of AAD components is set * to zero."" */ -aes_siv_encrypt (dpp->ke, dpp->key_len, wrapped2_plaintext, - dpp->key_len +4 ,NULL ,0 , wrapped2); +if (!aes_siv_encrypt (dpp->ke, dpp->key_len, wrapped2_plaintext, + dpp->key_len +4 ,NULL ,0 , wrapped2)) { +l_error ("Failed to encrypt wrapped data" ); +return ; + } wrapped2_len +=16 ;
Signature · 1 line
2.34.1
Denis Kenzior
AppliedRe: [PATCH 3/3] dpp: check return of aes_siv_encrypt
Hi James,
Quoted 8 lines · James Prestwood
This was caught by static analysis. As is common this should never happen in the real world since the only way this can fail (apart from extreme circumstances like OOM) is if the key size is incorrect, which it will never be.
--- src/dpp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Applied, thanks.
Regards,
-Denis
Denis Kenzior
AppliedQuoted 10 lines · James Prestwood
This was caught by static analysis and shouldn't ever happen.
--- tools/hwsim.c | 3 +++ 1 file changed, 3 insertions(+)tools/hwsim.c +0
-0
tools/hwsim.c static void get_radio_callback(struct l_genl_msg *msg, void *user_data) · line 644
Quoted 6 lines
tools/hwsim.c +3
-0@@ -639,6 +639,9 @@ static void get_radio_callback(struct l_genl_msg *msg, void *user_data)break ;case HWSIM_ATTR_RADIO_NAME : +if (name) +return ; +
I changed this to break instead of return.
tools/hwsim.c static void get_radio_callback(struct l_genl_msg *msg, void *user_data) · line 647
Quoted 4 lines
tools/hwsim.c +0
-0name =l_strndup (data, len);break ; }
Applied, thanks.
Regards,
-Denis