Re: getpwuid_r causes core dumps

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
2010/11/15 Peter C. Norton <[email protected]>:
> 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
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.