Bug 6843 - getaddrinfo_a segfaults
Summary: getaddrinfo_a segfaults
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-14 20:44 UTC by Aurelien Jarno
Modified: 2014-07-02 07:52 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2008-08-14 20:44:34 UTC
The following code segfaults with at least glibc >= 2.7 (and CVS). It works 
correctly with versions 2.3.X. I have tested versions in between.

#define _GNU_SOURCE

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

int
main (void)
{
#define N 10
  struct gaicb reqmem[N];
  struct gaicb *req[N];
  int n;

  for (n = 0; n < N; ++n)
    {
      asprintf (&reqmem[n].ar_name, "test%d.test.redhat.com", 140 + n);
      reqmem[n].ar_service = NULL;
      reqmem[n].ar_request = NULL;
      reqmem[n].ar_result = NULL;
      req[n] = &reqmem[n];
    }

  getaddrinfo_a (GAI_NOWAIT, req, N, NULL);
  
  return 0;
}
Comment 1 Ulrich Drepper 2008-11-01 00:19:51 UTC
Fixed in cvs.