pinakes-core: fix subtitle i32 overflow in postgres
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I3b43f97c96905953fd58f051667c59096a6a6964
This commit is contained in:
parent
60452dcb5a
commit
6d68a83003
4 changed files with 33 additions and 8 deletions
|
|
@ -3721,8 +3721,20 @@ impl StorageBackend for PostgresBackend {
|
|||
.map(|p| p.to_string_lossy().to_string());
|
||||
let track_index = subtitle
|
||||
.track_index
|
||||
.map(|i| i32::try_from(i).unwrap_or(i32::MAX));
|
||||
let offset_ms = i32::try_from(subtitle.offset_ms).unwrap_or(i32::MAX);
|
||||
.map(|i| {
|
||||
i32::try_from(i).map_err(|_| {
|
||||
PinakesError::InvalidOperation(format!(
|
||||
"subtitle track_index {i} exceeds i32 range"
|
||||
))
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
let offset_ms = i32::try_from(subtitle.offset_ms).map_err(|_| {
|
||||
PinakesError::InvalidOperation(format!(
|
||||
"subtitle offset_ms {} exceeds i32 range",
|
||||
subtitle.offset_ms
|
||||
))
|
||||
})?;
|
||||
client
|
||||
.execute(
|
||||
"INSERT INTO subtitles (id, media_id, language, format, file_path, \
|
||||
|
|
@ -3809,7 +3821,11 @@ impl StorageBackend for PostgresBackend {
|
|||
.get()
|
||||
.await
|
||||
.map_err(|e| PinakesError::Database(format!("pool error: {e}")))?;
|
||||
let offset = i32::try_from(offset_ms).unwrap_or(i32::MAX);
|
||||
let offset = i32::try_from(offset_ms).map_err(|_| {
|
||||
PinakesError::InvalidOperation(format!(
|
||||
"subtitle offset_ms {offset_ms} exceeds i32 range"
|
||||
))
|
||||
})?;
|
||||
client
|
||||
.execute("UPDATE subtitles SET offset_ms = $1 WHERE id = $2", &[
|
||||
&offset, &id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue