Skip to content

Commit 5e8497d

Browse files
Merge pull request #14 from thunderstore-io/fix-version-overflow
Fix u32 overflow when parsing package references with ridiculously large/long version numbers
2 parents 8dd0659 + 548d6ae commit 5e8497d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ts/version.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use serde_with::{DeserializeFromStr, SerializeDisplay};
77
SerializeDisplay, DeserializeFromStr, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
88
)]
99
pub struct Version {
10-
pub major: u32,
11-
pub minor: u32,
12-
pub patch: u32,
10+
pub major: u64,
11+
pub minor: u64,
12+
pub patch: u64,
1313
}
1414

1515
impl Version {
16-
pub const fn new(major: u32, minor: u32, patch: u32) -> Version {
16+
pub const fn new(major: u64, minor: u64, patch: u64) -> Version {
1717
Version {
1818
major,
1919
minor,
@@ -34,12 +34,12 @@ impl FromStr for Version {
3434
type Err = VersionParseError;
3535

3636
fn from_str(s: &str) -> Result<Self, Self::Err> {
37-
let [major, minor, patch]: [u32; 3] = s
37+
let [major, minor, patch]: [u64; 3] = s
3838
.splitn(3, '.')
3939
.map(|n| n.parse())
4040
.collect::<Result<Vec<_>, _>>()?
4141
.try_into()
42-
.map_err(|v: Vec<u32>| VersionParseError::DotCount(v.len() - 1))?;
42+
.map_err(|v: Vec<u64>| VersionParseError::DotCount(v.len() - 1))?;
4343

4444
Ok(Version {
4545
major,

0 commit comments

Comments
 (0)