From 1da2d8890bafd69ae7f475f551380c3fda106021 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Mon, 19 Aug 2024 00:29:33 +0800 Subject: [PATCH] remove err details from err CB to logger, for avoid leaking private information --- BlueMapCommon/webapp/public/sql.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/BlueMapCommon/webapp/public/sql.php b/BlueMapCommon/webapp/public/sql.php index 649a2361..5cd1cbd8 100644 --- a/BlueMapCommon/webapp/public/sql.php +++ b/BlueMapCommon/webapp/public/sql.php @@ -150,7 +150,8 @@ if (startsWith($path, "/maps/")) { $sql = new PDO("$driver:host=$hostname;port=$port;dbname=$database", $username, $password); $sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e ) { - error(500, "Failed to connect to database: ".$e->getMessage()); + error_log($e->getMessage(), 0); // Logs the detailed error message + error(500, "Failed to connect to database"); } // provide map-tiles @@ -201,7 +202,10 @@ if (startsWith($path, "/maps/")) { exit; } - } catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); } + } catch (PDOException $e) { + error_log($e->getMessage(), 0); + error(500, "Failed to fetch data"); + } // no content if nothing found http_response_code(204); @@ -240,7 +244,10 @@ if (startsWith($path, "/maps/")) { send($line["data"]); exit; } - } catch (PDOException $e) { error(500, "Failed to fetch data: ".$e->getMessage()); } + } catch (PDOException $e) { + error_log($e->getMessage(), 0); + error(500, "Failed to fetch data"); + } } }