From a25e0f1956dc2429efc01b8e242746316198947f Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 13 Dec 2025 12:13:28 +0100 Subject: [PATCH] Fix TypeError when hostapd config parsing fails --- app/img/wifi-qr-code.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/img/wifi-qr-code.php b/app/img/wifi-qr-code.php index 19171094..a0017c3a 100755 --- a/app/img/wifi-qr-code.php +++ b/app/img/wifi-qr-code.php @@ -12,6 +12,12 @@ if (!isset($_SERVER['HTTP_REFERER'])) { $hostapd = parse_ini_file(RASPI_HOSTAPD_CONFIG, false, INI_SCANNER_RAW); +// handle parse failure +if ($hostapd === false) { + header('HTTP/1.0 500 Internal Server Error'); + exit('Error: Unable to parse hostapd configuration'); +} + // assume WPA encryption and get the passphrase $type = "WPA"; $password = isset($hostapd['wpa_psk']) ? $hostapd['wpa_psk'] : $hostapd['wpa_passphrase'];