Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/extensions-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:

jobs:
c-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
defaults:
run:
working-directory: libsql-sqlite3
Expand All @@ -41,7 +41,7 @@ jobs:
make test

rs-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
defaults:
run:
working-directory: libsql-sqlite3
Expand All @@ -61,7 +61,7 @@ jobs:
cargo test --features=loadable_extension

extensions-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
name: Extensions Tests

steps:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/golang-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
golang-bindings:

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

services:
sqld:
Expand All @@ -37,7 +37,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.21'
# 1.27.4 rejects the LTO section in the static lib built above (".llvmbc" in
# #cgo LDFLAGS); 1.27.3 is the last version that builds go-libsql.
go-version: '1.27.3'
- name: get TCL
run: sudo apt-get install -y tcl8.6-dev

Expand Down
28 changes: 24 additions & 4 deletions vendored/sqlite3-parser/src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ impl TokenType {
}
}

// Input bytes are not validated as UTF-8 before parsing, so never assume they are.
// Upstream gwenn/lemon-rs 14f422a (CVE-2025-47736).
fn from_bytes(bytes: &[u8]) -> String {
unsafe { str::from_utf8_unchecked(bytes).to_owned() }
String::from_utf8_lossy(bytes).to_string()
}

include!(concat!(env!("OUT_DIR"), "/keywords.rs"));
pub(crate) const MAX_KEYWORD_LEN: usize = 17;

pub fn keyword_token(word: &[u8]) -> Option<TokenType> {
KEYWORDS
.get(UncasedStr::new(unsafe { str::from_utf8_unchecked(word) }))
.cloned()
// Invalid UTF-8 can never spell a keyword.
let word = str::from_utf8(word).ok()?;
KEYWORDS.get(UncasedStr::new(word)).cloned()
}

pub(crate) fn is_identifier(name: &str) -> bool {
Expand Down Expand Up @@ -403,3 +405,21 @@ impl TokenType {
}
}
}

#[cfg(test)]
mod invalid_utf8_tests {
use super::{from_bytes, keyword_token};

// CVE-2025-47736: non-UTF-8 input must not panic the parser.
#[test]
fn invalid_utf8_is_not_a_keyword() {
assert_eq!(keyword_token(&[0xff, 0xfe, b'x']), None);
assert_eq!(keyword_token(b"select"), keyword_token(b"SELECT"));
assert!(keyword_token(b"select").is_some());
}

#[test]
fn invalid_utf8_bytes_are_replaced() {
assert_eq!(from_bytes(&[b'a', 0xff, b'b']), "a\u{fffd}b");
}
}
Loading