Skip to Content.
Sympa Menu

freetds - Re: [freetds] getpwuid_r causes core dumps

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] getpwuid_r causes core dumps
  • Date: Tue, 16 Nov 2010 11:33:34 +0100

2010/11/15 Peter C. Norton <spacey-freetds.org AT ssr.com>:
> In a recent test our users saw that freetds was core dumping in
> threadsafe.c.  The following is the issue:
>
> diff -u -r1.1.1.5 -r1.2
> --- threadsafe.c        17 Sep 2010 17:11:06 -0000      1.1.1.5
> +++ threadsafe.c        15 Nov 2010 22:37:41 -0000      1.2
> @@ -516,12 +516,14 @@
>  #ifndef _WIN32
>  /* if is available getpwuid_r use it */
>  #if defined(HAVE_GETUID) && defined(HAVE_GETPWUID_R)
> -       struct passwd *pw, bpw;
> +       struct passwd *pw = NULL, bpw;
>        char buf[1024];
>
>  # if defined(HAVE_FUNC_GETPWUID_R_5)
>        if (getpwuid_r(getuid(), &bpw, buf, sizeof(buf), &pw))
>                return NULL;
> +       if (pw == NULL)
> +           return NULL;
>
>  # elif defined(HAVE_FUNC_GETPWUID_R_4_PW)
>        if (!(pw = getpwuid_r(getuid(), &bpw, buf, sizeof(buf))))
>
> getpwuid_r can return 0 when a lookup hasn't found a matching entry.
> This seems to work for us, but it may be more correct to check errno.
>
> -Peter

Applied. No, in this case getpwuid_r return the error so checking pw
is the better way

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page