-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.P-mediumMedium priorityMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
xpepermint, stevenengler, seandewar and kswope
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.P-mediumMedium priorityMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
nagisa commentedon Mar 6, 2018
This is a function on the standard input though? What is the threat model? That you DoS your own computer?
BijanVan commentedon Mar 6, 2018
That is not limited to Tokio. TcpStream from standard library could be wrapped by BufReader.
Here is an example:
`use std::io::{BufRead, BufReader};
use std::net::TcpListener;
fn main() {
let listener = TcpListener::bind("localhost:8080").unwrap();
}
`
Mark-Simulacrum commentedon Mar 7, 2018
This somewhat feels like something the user should be aware of. It's also not clear to me that there's much we can/should do about this -- an arbitrary limit on our side would be decidedly odd (and potentially break some use cases). Users using and of the
read
methods should be aware that they are both blocking and may not return (ever, potentially). This seems semi-obvious to me... but perhaps we could clarify it in documentation.BijanVan commentedon Mar 7, 2018
I guess adding
fn read_line(&mut self, buf: &mut String, max_length: usize) -> Result
in addition to:
fn read_line(&mut self, buf: &mut String) -> Result
would not break anything.
Mark-Simulacrum commentedon Mar 7, 2018
That should be done via
Read::take
, so I'm not sure that it's entirely useful. Anyway, it almost seems like this is a too specific thing to add - in most cases, I'd imagine that if you want to limit the potential line length, you'd want a different return type, among maybe other things. Since I'd imagine they'd be fairly specific to each use case it seems easier for users to implement that on their own viaread
or a similar call.alexcrichton commentedon Mar 21, 2018
We discussed this during libs triage today and the conclusion was that we didn't consider this a bug to fix in libstd but would of course be more than willing to update the documentation. As a result I'm reclassifying as a documentation issue.
frewsxcv commentedon Mar 28, 2018
Note to future selves: if we put a note about this on
BufRead::read_line
, we should consider adding a note onBufRead::read_until
too since it's susceptible to the same issueRollup merge of rust-lang#72888 - poliorcetics:improve-read_line-read…
poliorcetics commentedon Jun 3, 2020
If the added doc is deemed sufficient, this should be closed, though I do not know who to ping for that.