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:
Richard Frith-MacDonald 2007-12-19 14:54:00 +00:00
parent e980ba412c
commit 5850f8f3a4
2 changed files with 14 additions and 7 deletions

View file

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

View file

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