freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Peter C. Norton" <spacey-freetds.org AT ssr.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] getpwuid_r causes core dumps
- Date: Mon, 15 Nov 2010 17:42:00 -0500
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
-
[freetds] getpwuid_r causes core dumps,
Peter C. Norton, 11/15/2010
- Re: [freetds] getpwuid_r causes core dumps, Frediano Ziglio, 11/16/2010
Archive powered by MHonArc 2.6.24.