Bug 449358 - nscd breaks getservbyport()
nscd breaks getservbyport()
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
9
i386 Linux
low Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-02 07:57 EDT by Roman Kagan
Modified: 2008-07-23 03:08 EDT (History)
0 users

See Also:
Fixed In Version: 2.8-8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-07-23 03:08:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
potential fix (untested) (663 bytes, patch)
2008-06-02 08:59 EDT, Roman Kagan
no flags Details | Diff

  None (edit)
Description Roman Kagan 2008-06-02 07:57:10 EDT
Description of problem:
When nscd is running, getservbyport() returns garbage.

With stock /etc/services, it returns spr-itunes (0 port) for any query.  With 0
port removed from /etc/services, it returns NULL for any query.

Version-Release number of selected component (if applicable):
glibc-2.8-3.i686
nscd-2.8-3.i386
setup-2.6.14-1.fc9.noarch

How reproducible:
always

Steps to Reproduce:

Use the following program:

#include <netdb.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	struct servent *s;
	s = getservbyport(htons(atoi(argv[1])), argv[2]);
	if (s)
		printf("%s\n", s->s_name);
	else
		printf("port not found\n");
}


Without nscd everything is fine:

# service nscd stop
Stopping nscd:                                             [  OK  ]
# ./bug 25 tcp
smtp
# ./bug 7425 tcp
port not found


With nscd and 0 port in /etc/services (stock /etc/services from setup package):

# awk '$2 == "0/tcp" {print}' /etc/services
spr-itunes	0/tcp			# Shirt Pocket netTunes
spl-itunes	0/tcp			# Shirt Pocket launchTunes
# service nscd stop
Stopping nscd:                                             [FAILED]
# rm -f /var/db/nscd/*
# service nscd start
Starting nscd:                                             [  OK  ]
# ./bug 25 tcp
spr-itunes
# ./bug 7425 tcp
spr-itunes


With nscd and without 0 port in /etc/services:

# awk '$2 != "0/tcp"' /etc/services > /etc/services.nozero
# cat /etc/services.nozero > /etc/services
# service nscd stop
Stopping nscd:                                             [FAILED]
# rm -f /var/db/nscd/*
# service nscd start
Starting nscd:                                             [  OK  ]
# ./bug 25 tcp
port not found
# ./bug 7425 tcp
port not found
Comment 1 Roman Kagan 2008-06-02 08:59:14 EDT
Created attachment 307357 [details]
potential fix (untested)

Seems like the problem is in __nscd_getservbyport_r(), where the port is
converted to a string at the end of the buffer, but then the beginning of the
buffer is passed down to nscd_getserv_r().
Comment 2 Jakub Jelinek 2008-06-03 06:51:07 EDT
Thanks, looks correct, applied to CVS.
Comment 3 Jakub Jelinek 2008-06-15 18:42:21 EDT
Fixed in rawhide glibc and will be eventually backported.
Comment 4 Fedora Update System 2008-07-08 16:27:23 EDT
glibc-2.8-7 has been submitted as an update for Fedora 9
Comment 5 Fedora Update System 2008-07-23 03:08:21 EDT
glibc-2.8-8 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.