Fixup nul pointer issues

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25760 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-12-19 14:54:00 +00:00
parent f6148c5a48
commit 637e76c37b
2 changed files with 14 additions and 7 deletions

View file

@ -411,10 +411,11 @@ static NSStringEncoding defaultEncoding;
#ifdef HAVE_PWD_H
#if defined(HAVE_GETPWNAM_R)
struct passwd pw;
struct passwd *p;
char buf[BUFSIZ*10];
if (getpwnam_r([str cStringUsingEncoding: defaultEncoding],
&pw, buf, sizeof(buf), 0) == 0)
&pw, buf, sizeof(buf), &p) == 0)
{
ok = (chown(lpath, pw.pw_uid, -1) == 0);
chown(lpath, -1, pw.pw_gid);
@ -463,10 +464,11 @@ static NSStringEncoding defaultEncoding;
#ifdef HAVE_GRP_H
#ifdef HAVE_GETGRNAM_R
struct group gp;
struct group *p;
char buf[BUFSIZ*10];
if (getgrnam_r([str cStringUsingEncoding: defaultEncoding], &gp,
buf, sizeof(buf), 0) == 0)
buf, sizeof(buf), &p) == 0)
{
if (chown(lpath, -1, gp.gr_gid) == 0)
ok = YES;
@ -2970,9 +2972,10 @@ static NSSet *fileKeys = nil;
#if defined(HAVE_GRP_H)
#if defined(HAVE_GETGRGID_H)
struct group gp;
struct group *p;
char buf[BUFSIZ*10];
if (getgrgid_r(statbuf.st_gid, &gp, buf, sizeof(buf), 0) == 0)
if (getgrgid_r(statbuf.st_gid, &gp, buf, sizeof(buf), &p) == 0)
{
group = [NSString stringWithCString: gp.gr_name
encoding: defaultEncoding];
@ -3126,9 +3129,10 @@ static NSSet *fileKeys = nil;
#ifdef HAVE_PWD_H
#if defined(HAVE_GETPWUID_R)
struct passwd pw;
struct passwd *p;
char buf[BUFSIZ*10];
if (getpwuid_r(statbuf.st_uid, &pw, buf, sizeof(buf), 0) == 0)
if (getpwuid_r(statbuf.st_uid, &pw, buf, sizeof(buf), &p) == 0)
{
owner = [NSString stringWithCString: pw.pw_name
encoding: defaultEncoding];

View file

@ -1267,9 +1267,10 @@ NSUserName(void)
const char *loginName = 0;
#if defined(HAVE_GETPWUID_R)
struct passwd pwent;
struct passwd *p;
char buf[BUFSIZ*10];
if (getpwuid_r(uid, &pwent, buf, sizeof(buf), 0) == 0)
if (getpwuid_r(uid, &pwent, buf, sizeof(buf), &p) == 0)
{
loginName = pwent.pw_name;
}
@ -1316,9 +1317,10 @@ NSHomeDirectoryForUser(NSString *loginName)
#if !defined(__MINGW32__)
#if defined(HAVE_GETPWNAM_R)
struct passwd pw;
struct passwd *p;
char buf[BUFSIZ*10];
if (getpwnam_r([loginName cString], &pw, buf, sizeof(buf), 0) == 0
if (getpwnam_r([loginName cString], &pw, buf, sizeof(buf), &p) == 0
&& pw.pw_dir != 0)
{
s = [NSString stringWithUTF8String: pw.pw_dir];
@ -1398,9 +1400,10 @@ NSFullUserName(void)
#ifdef HAVE_PWD_H
#if defined(HAVE_GETPWNAM_R)
struct passwd pw;
struct passwd *p;
char buf[BUFSIZ*10];
if (getpwnam_r([NSUserName() cString], &pw, buf, sizeof(buf), 0) == 0)
if (getpwnam_r([NSUserName() cString], &pw, buf, sizeof(buf), &p) == 0)
{
userName = [NSString stringWithUTF8String: pw.pw_gecos];
}