Skip to content

Commit

Permalink
fix(postgres) use signed int for length prefix in PgCopyIn (#3701)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydewaal authored Jan 24, 2025
1 parent a83395a commit a408c49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sqlx-postgres/src/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
}

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

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

conn.inner.stream.flush().await?;
}
Expand Down

0 comments on commit a408c49

Please sign in to comment.