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

Infinite loop in parse::find_port #20

Closed
xiaozhiyan opened this issue Aug 20, 2023 · 2 comments
Closed

Infinite loop in parse::find_port #20

xiaozhiyan opened this issue Aug 20, 2023 · 2 comments

Comments

@xiaozhiyan
Copy link

xiaozhiyan commented Aug 20, 2023

Hi, thanks for releasing iref v3.0.0.
I'm trying to use the new version in hadoop-rust, but I've found that the function Authority::port does not return.
The issue seems to be caused by an infinite loop in parse::find_port.
Please help to fix it when convenient.

(Here's a temporary fix for it.)

% git diff src/common/parse.rs
diff --git a/src/common/parse.rs b/src/common/parse.rs
index 3980802..8eb90ab 100644
--- a/src/common/parse.rs
+++ b/src/common/parse.rs
@@ -276,9 +276,10 @@ pub fn find_port(bytes: &[u8], mut i: usize) -> Option<Range<usize>> {
                                        i += 1;
                                        continue 'host;
                                }
+                               i += 1;
                        }

-                       return Some(start..i);
+                       return Some(start..i - 1);
                }

                i += 1
@timothee-haudebourg
Copy link
Owner

Thanks for the report, I'm missing some tests there. I've fixed the function, I'll just cover every function of the module with tests and update the crate.

@timothee-haudebourg
Copy link
Owner

Fix published with version 3.0.1

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

No branches or pull requests

2 participants