Bug 61492 - getXXbyYY performs an extra close on nis/nisplu lookups
Summary: getXXbyYY performs an extra close on nis/nisplu lookups
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 7.2
Hardware: i386 Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-03-20 17:13 UTC by Issue Tracker
Modified: 2016-11-24 14:58 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-21 14:42:48 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch from Uli likely to fix this. (1.22 KB, patch)
2002-03-21 14:42 UTC, Issue Tracker
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2002:056 contract SHIPPED_LIVE GNU C Library bugfix update 2002-04-02 05:00:00 UTC

Description Issue Tracker 2002-03-20 17:13:44 UTC
Description of Problem:


        #include <netdb.h>

        int main(int argc, char **argv )
        {
                write(1,"A\n",2);
                getservbyname(argv[1],0);
                write(1,"B\n",2);
                return 0;
        }

If I run this with an undefined service name (such as "quack"), I see glibc
trying to close an fd it shouldn't be:

        close(3)                       = 0
        close(3)                       = 0
        A
        close(3)                       = 0
        close(3)                       = 0        close(3)                       = 0
        close(3)                       = 0
        close(3)                       = 0
        close(3)                       = 0
        close(3)                       = 0
        close(3)                       = 0
        close(4)                       = 0
        close(3)                       = 0
        close(4)                       = -1 EBADF (Bad file descriptor)
        close(3)                       = 0
        B

Note, this also happens if nis/nisplus is used before files for service lookups,
and whether a valid service name is used or not. 

If files are checked first, and the lookup succeeds the excess close does not
happen. 

In a multithreaded application the potential exists for reassignment of the fd
before the second (erroneous) close.

Comment 1 Issue Tracker 2002-03-21 14:42:44 UTC
Created attachment 49404 [details]
Patch from Uli likely to fix this.

Comment 2 Jakub Jelinek 2002-04-05 09:00:49 UTC
Fixed in glibc-2.2.4-24.


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