Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps, fix new sqlx usage #1428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

nyurik
Copy link
Member

@nyurik nyurik commented Jul 23, 2024

Resolves #1475

Comment on lines +397 to +400
#[allow(clippy::cast_possible_truncation)]
let min_zoom = validate_zoom(info.min_zoom.map(|v| v as i32), "zoom_level")?;
#[allow(clippy::cast_possible_truncation)]
let max_zoom = validate_zoom(info.max_zoom.map(|v| v as i32), "zoom_level")?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the truncation here is the best option.

fn validate_zoom does check if the value can be casted to u8 via u8::try_from

Changing to fn validate_zoom(zoom: Option<i64>, zoom_name: &'static str) -> MbtResult<Option<u8>> seems like a better option

Suggested change
#[allow(clippy::cast_possible_truncation)]
let min_zoom = validate_zoom(info.min_zoom.map(|v| v as i32), "zoom_level")?;
#[allow(clippy::cast_possible_truncation)]
let max_zoom = validate_zoom(info.max_zoom.map(|v| v as i32), "zoom_level")?;
let min_zoom = validate_zoom(info.min_zoom, "zoom_level")?;
let max_zoom = validate_zoom(info.max_zoom, "zoom_level")?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RUSTSEC-2024-0363: Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts
2 participants