Skip to contentSkip to conversation

fils: pragma false positive for uninitialized variable

PATCH Applied James Prestwood 2 participants 2 messages Jun 10, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/1 fils: pragma false positive for uninitialized variable

On musl-gcc the compiler is giving a warning for igtk_key_index and gtk_key_index being used uninitialized. This isn't possible since they are only used if gtk/igtk are non-NULL so pragma to ignore the warning.

src/fils.c: In function 'fils_rx_associate':
src/fils.c:580:17: error: 'igtk_key_index' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
580 | handshake_state_install_igtk(fils->hs,

					igtk_key_index,igtk + 6,
					igtk_len - 6, igtk);

(same error for gtk_key_index)

---
 src/fils.c | 3 +++
 1 file changed, 3 insertions(+)
src/fils.c +3 -0
index d1d46d65..c3337352 100644
@@ -572,6 +572,8 @@ static int fils_rx_associate(struct auth_proto *driver, const uint8_t *frame,
 	handshake_state_set_pmk(fils->hs, fils->pmk, fils->pmk_len);
 	handshake_state_set_pmkid(fils->hs, fils->pmkid);
 
+_Pragma("GCC diagnostic push")
+_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
 	if (gtk)
 		handshake_state_install_gtk(fils->hs, gtk_key_index, gtk,
 						gtk_len, key_rsc, 6);
@@ -579,6 +581,7 @@ static int fils_rx_associate(struct auth_proto *driver, const uint8_t *frame,
 	if (igtk)
 		handshake_state_install_igtk(fils->hs, igtk_key_index,
 						igtk + 6, igtk_len - 6, igtk);
+_Pragma("GCC diagnostic pop")
 
 	handshake_state_set_ptk(fils->hs, fils->kek_and_tk, fils->kek_len + 16);
 	handshake_state_install_ptk(fils->hs);
Signature · 1 line
2.34.1
Applied
#1 lore raw

Hi James,

Quoted 9 lines · James Prestwood

On musl-gcc the compiler is giving a warning for igtk_key_index and gtk_key_index being used uninitialized. This isn't possible since they are only used if gtk/igtk are non-NULL so pragma to ignore the warning.

src/fils.c: In function 'fils_rx_associate':
src/fils.c:580:17: error: 'igtk_key_index' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
580 | handshake_state_install_igtk(fils->hs,

Quoted 8 lines
					igtk_key_index,igtk + 6,
					igtk_len - 6, igtk);

(same error for gtk_key_index)

---
  src/fils.c | 3 +++
  1 file changed, 3 insertions(+)

Applied, thanks.

Regards,
-Denis