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 1e14adf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ impl FromStr for ServiceWithPort {

impl ServiceWithPort {
fn lookup(&self) -> Result<Option<Service>> {
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 1e14adf

Please sign in to comment.