Skip to content

Commit

Permalink
fix: audit sqlx_postgres::types::array for bad casts
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Aug 16, 2024
1 parent 7cfda30 commit ac0448c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sqlx-postgres/src/types/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ where
}
}

buf.extend(&(self.len() as i32).to_be_bytes()); // len
let array_len = i32::try_from(self.len()).map_err(|_| {
format!(
"encoded array length is too large for Postgres: {}",
self.len()
)
})?;

buf.extend(array_len.to_be_bytes()); // len
buf.extend(&1_i32.to_be_bytes()); // lower bound

for element in self.iter() {
Expand Down

0 comments on commit ac0448c

Please sign in to comment.