Skip to content

Commit

Permalink
Getservbyport should refuse port 0
Browse files Browse the repository at this point in the history
issue-142

If nsncd queries sssd for port 0, ENOMEM is returned causing error logs.
This has been confirmed by using the getservbyport_r man page example
and amending nsswitch.conf
  • Loading branch information
morisja committed Oct 21, 2024
1 parent f6b4edd commit bd06f28
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ impl FromStr for ServiceWithPort {

impl ServiceWithPort {
fn lookup(&self) -> Result<Option<Service>> {
//issue-142
//port 0 lookups to sssd return ENOMEM
if self.port == 0 {
return Ok(None);
}
let proto = match &self.proto {
Some(p) => Some(CString::new(p.clone())?),
None => None,
Expand Down

0 comments on commit bd06f28

Please sign in to comment.