Skip to content

Commit a408c49

Browse files
authored
fix(postgres) use signed int for length prefix in PgCopyIn (#3701)
1 parent a83395a commit a408c49

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-postgres/src/copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
230230
}
231231

232232
// Write the length
233-
let read32 = u32::try_from(read)
234-
.map_err(|_| err_protocol!("number of bytes read exceeds 2^32: {}", read))?;
233+
let read32 = i32::try_from(read)
234+
.map_err(|_| err_protocol!("number of bytes read exceeds 2^31 - 1: {}", read))?;
235235

236-
(&mut buf.get_mut()[1..]).put_u32(read32 + 4);
236+
(&mut buf.get_mut()[1..]).put_i32(read32 + 4);
237237

238238
conn.inner.stream.flush().await?;
239239
}

0 commit comments

Comments
 (0)