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

Fix capacity overflow for list command #176

Merged
merged 5 commits into from
Jan 17, 2024
Merged

Conversation

MordechaiHadad
Copy link
Owner

No description provided.

@MordechaiHadad MordechaiHadad changed the title change: only put sub directories in vector Fix capacity overflow for list command Dec 28, 2023
@Amar1729
Copy link

Hm, no dice:

❯  ./target/debug/bob list
┌───────────┬─────────────┐
│  Version  │  Status     │
├───────────┼─────────────┤
│  v0.9.0   │  Installed  │
│  nightly  │  Used       │
thread 'main' panicked at src/handlers/list_handler.rs:56:26:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looks like I have nightly-5651c1f installed. its path_name.len() is 15, which is causing an overflow with version_max_len - path_name.len() (7 - 15).

If i set version_max_len = 16 explicitly it prints out fine. I'm not sure how 5651c1f got installed, but it doesn't match the regex in src/helpers/version/nightly.rs, which specifies 8 hex chars. I changed it to nightly-[a-zA-Z0-9]{7,8}, which matches the version i have downloaded properly and results in version_max_len being properly set to 16.

However I'm not sure what's the right approach here? Should the rollback nightly regex be loosened?

@MordechaiHadad
Copy link
Owner Author

anything from this commit?

@sungyoonc
Copy link

The code expects the hash after nightly- to be 8 characters, but the created nightly rollbacks have 7 character after nightly-.
The command bob list and bob rollback works when I change the directory name from nightly-ec74538 to nightly-ec74538f.

In src/handlers/list_handler.rs

let alphanumeric_regex = Regex::new(r"^[a-zA-Z0-9]{8}$").unwrap();

Also at produce_nightly_vec() in src/helpers/version/nightly.rs (for rollback command)

let regex = Regex::new(r"nightly-[a-zA-Z0-9]{8}")?;

@MordechaiHadad
Copy link
Owner Author

The code expects the hash after nightly- to be 8 characters, but the created nightly rollbacks have 7 character after nightly-. The command bob list and bob rollback works when I change the directory name from nightly-ec74538 to nightly-ec74538f.

In src/handlers/list_handler.rs

let alphanumeric_regex = Regex::new(r"^[a-zA-Z0-9]{8}$").unwrap();

Also at produce_nightly_vec() in src/helpers/version/nightly.rs (for rollback command)

let regex = Regex::new(r"nightly-[a-zA-Z0-9]{8}")?;

Ye I accidentally fucked it up, it used to generate it's own hash until i changed that and forgot to update, @Amar1729 is it better now? works for me when using both rollback with 7 and 8 characters after.

@Amar1729
Copy link

@MordechaiHadad forgot to reply, my bad. Yeah, seems like that works for me!

❯  ./target/debug/bob list
┌────────────────────┬─────────────┐
│  Version           │  Status     │
├────────────────────┼─────────────┤
│  v0.9.0            │  Installed  │
│  nightly           │  Used       │
│  nightly-5651c1f   │  Installed  │
│  v0.9.4            │  Installed  │
└────────────────────┴─────────────┘

@MordechaiHadad MordechaiHadad merged commit 8791623 into master Jan 17, 2024
32 of 33 checks passed
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.

None yet

3 participants