janmojzis / tinyssh

TinySSH is small server (less than 100000 words of code)
Creative Commons Zero v1.0 Universal
1.43k stars 78 forks source link

Inconsistent behavior of getln() on error #65

Closed sfzhi closed 2 years ago

sfzhi commented 2 years ago

The getln() function behaves inconsistently w.r.t. closing the file descriptor on error - sometimes it does that, sometimes it doesn't. As the result, if getln() returns an error, the caller has no idea whether the file descriptor has been closed or not.

In general, closing the file descriptor is quite surprising behavior for such a function. If it is desirable for whatever reason, it would be nice to mention it in the comment describing the function.

janmojzis commented 2 years ago

fixed, thank for report!