From d2339036efa72a06fe23021a5c642405c9b04a5e Mon Sep 17 00:00:00 2001 From: Joaquin Hui Gomez <132194176+joaquinhuigomez@users.noreply.github.com> Date: Sat, 28 Mar 2026 23:28:08 +0000 Subject: [PATCH] fix: replace from_utf8_unchecked with from_utf8_lossy in SqliteError sqlite3_errmsg() returns UTF-8 in practice but the spec does not guarantee it. Using from_utf8_unchecked is unsound if non-UTF-8 bytes are returned (e.g. from malformed schema element names). Closes #4193 --- sqlx-sqlite/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-sqlite/src/error.rs b/sqlx-sqlite/src/error.rs index b4373d7a07..5510e25d97 100644 --- a/sqlx-sqlite/src/error.rs +++ b/sqlx-sqlite/src/error.rs @@ -39,7 +39,7 @@ impl SqliteError { let msg = sqlite3_errmsg(handle); debug_assert!(!msg.is_null()); - str::from_utf8_unchecked(CStr::from_ptr(msg).to_bytes()).to_owned() + String::from_utf8_lossy(CStr::from_ptr(msg).to_bytes()).into_owned() }; Some(Self {