This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nss/21915] New: nss_files can return with NSS_STATUS_SUCCESS and a clobbered errno value, causing getaddrinfo to fail


https://sourceware.org/bugzilla/show_bug.cgi?id=21915

            Bug ID: 21915
           Summary: nss_files can return with NSS_STATUS_SUCCESS and a
                    clobbered errno value, causing getaddrinfo to fail
           Product: glibc
           Version: 2.26
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nss
          Assignee: unassigned at sourceware dot org
          Reporter: fweimer at redhat dot com
  Target Milestone: ---

getaddrinfo has this code:

  while (1) {                                                                 \
    rc = 0;                                                                   \
    status = DL_CALL_FCT (fct, (name, _family, &th,                           \
                                tmpbuf->data, tmpbuf->length,                 \
                                &rc, &herrno, NULL, &localcanon));            \
    if (rc != ERANGE || herrno != NETDB_INTERNAL)                             \
      break;                                                                  \
    if (!scratch_buffer_grow (tmpbuf))                                        \
      {                                                                       \
        result = -EAI_MEMORY;                                                 \
        goto free_and_return;                                                 \
      }                                                                       \
  }                                                                           \
  if (status == NSS_STATUS_SUCCESS && rc == 0)                                \
    h = &th;                                                                  \
  else                                                                        \
    h = NULL;                                                                 \
  if (rc != 0)                                                                \

That is, *errnop (in the form of rc) takes precedence over the NSS return
status.

nss_files, in multi mode, will continue reading /etc/hosts after the first
match, to find additional addresses and aliases.  These subsequent reads can
perform ERANGE-based buffer resizing.  This means that errno is not 0 anymore,
and getaddrinfo will report an incorrect error.

I initially added this to bug 20532 comment 3, but it is not clear what this
bug is actually about anymore, so I'm tracking this separately.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]