Skip to content

Commit 93f9743

Browse files
committed
update rand to the latest version
1 parent b739cc1 commit 93f9743

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

Cargo.lock

Lines changed: 30 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ paste = "1.0.6"
144144
serde = { version = "1.0.132", features = ["derive"] }
145145
serde_json = "1.0.73"
146146
url = "2.2.2"
147-
rand = "0.8"
147+
rand = "0.9"
148148
rand_xoshiro = "0.7.0"
149149
hex = "0.4.3"
150150
tempdir = "0.3.7"

sqlx-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ memchr = { version = "2.4.1", default-features = false }
141141
num-bigint = { version = "0.4.0", default-features = false, optional = true, features = ["std"] }
142142
once_cell = "1.9.0"
143143
percent-encoding = "2.1.0"
144-
rand = { version = "0.8", default-features = false, optional = true, features = ["std", "std_rng"] }
144+
rand = { version = "0.9", default-features = false, optional = true, features = ["std_rng", "small_rng", "thread_rng"] }
145145
regex = { version = "1.5.5", optional = true }
146146
rsa = { version = "0.9.2", optional = true }
147147
rustls = { version = "0.23", optional = true }

sqlx-core/src/postgres/connection/establish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl PgConnection {
146146
transaction_status,
147147
transaction_depth: 0,
148148
pending_ready_for_query_count: 0,
149-
next_statement_id: Oid(rand::thread_rng().gen()),
149+
next_statement_id: Oid(rand::rng().random()),
150150
cache_statement: StatementCache::new(options.statement_cache_capacity),
151151
cache_type_oid: HashMap::new(),
152152
cache_type_info: HashMap::new(),

sqlx-core/src/postgres/connection/sasl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ pub(crate) async fn authenticate(
6363
};
6464

6565
// nonce = "r=" c-nonce [s-nonce] ;; Second part provided by server.
66-
let nonce = gen_nonce();
66+
let client_nonce = gen_nonce();
6767

6868
// client-first-message-bare = [reserved-mext ","] username "," nonce ["," extensions]
6969
let client_first_message_bare =
70-
format!("{username},{nonce}", username = username, nonce = nonce);
70+
format!("{username},{client_nonce}", username = username, client_nonce = client_nonce);
7171

7272
let client_first_message = format!(
7373
"{gs2_header}{client_first_message_bare}",
@@ -174,19 +174,19 @@ pub(crate) async fn authenticate(
174174

175175
// nonce is a sequence of random printable bytes
176176
fn gen_nonce() -> String {
177-
let mut rng = rand::thread_rng();
178-
let count = rng.gen_range(64..128);
177+
let mut rng = rand::rng();
178+
let count = rng.random_range(64..128);
179179

180180
// printable = %x21-2B / %x2D-7E
181181
// ;; Printable ASCII except ",".
182182
// ;; Note that any "printable" is also
183183
// ;; a valid "value".
184184
let nonce: String = std::iter::repeat(())
185185
.map(|()| {
186-
let mut c = rng.gen_range(0x21..0x7F) as u8;
186+
let mut c = rng.random_range(0x21..0x7F) as u8;
187187

188188
while c == 0x2C {
189-
c = rng.gen_range(0x21..0x7F) as u8;
189+
c = rng.random_range(0x21..0x7F) as u8;
190190
}
191191

192192
c
@@ -195,7 +195,7 @@ fn gen_nonce() -> String {
195195
.map(|c| c as char)
196196
.collect();
197197

198-
rng.gen_range(32..128);
198+
rng.random_range(32..128);
199199
format!("{}={}", NONCE_ATTR, nonce)
200200
}
201201

0 commit comments

Comments
 (0)