Bug 61492 - getXXbyYY performs an extra close on nis/nisplu lookups
getXXbyYY performs an extra close on nis/nisplu lookups
Status: CLOSED ERRATA
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-03-20 12:13 EST by Issue Tracker
Modified: 2016-11-24 09:58 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-21 09:42:48 EST
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 09:42 EST, Issue Tracker
no flags Details | Diff

  None (edit)
Description Issue Tracker 2002-03-20 12:13:44 EST
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 09:42:44 EST
Created attachment 49404 [details]
Patch from Uli likely to fix this.
Comment 2 Jakub Jelinek 2002-04-05 04:00:49 EST
Fixed in glibc-2.2.4-24.

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