summaryrefslogtreecommitdiff
path: root/modules/pam_mkhomedir/pam_mkhomedir.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2005-01-25 10:43:11 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2005-01-25 10:43:11 +0000
commitad88185d0f2d5e59479224a0fcdb1e8c11a6f012 (patch)
tree62b3c10e9b4dabcd2e4d34b453a87b7506ba5400 /modules/pam_mkhomedir/pam_mkhomedir.c
parent8533e9b7645c0908da2755d00f31de1aaa833b27 (diff)
Relevant BUGIDs: 1106011
Purpose of commit: bugfix Commit summary: --------------- Fix compilation on systems without PATH_MAX
Diffstat (limited to 'modules/pam_mkhomedir/pam_mkhomedir.c')
-rw-r--r--modules/pam_mkhomedir/pam_mkhomedir.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/pam_mkhomedir/pam_mkhomedir.c b/modules/pam_mkhomedir/pam_mkhomedir.c
index f2f92974..f63177bf 100644
--- a/modules/pam_mkhomedir/pam_mkhomedir.c
+++ b/modules/pam_mkhomedir/pam_mkhomedir.c
@@ -222,10 +222,10 @@ static int create_homedir(pam_handle_t * pamh, int ctrl,
int Res;
struct stat St;
#ifndef PATH_MAX
- char *newsource = NULL; *newdest = NULL;
+ char *newsource = NULL, *newdest = NULL;
/* track length of buffers */
int nslen = 0, ndlen = 0;
- slen = strlen(source), dlen = strlen(dest);
+ int slen = strlen(source), dlen = strlen(dest);
#else
char newsource[PATH_MAX], newdest[PATH_MAX];
#endif
@@ -237,11 +237,11 @@ static int create_homedir(pam_handle_t * pamh, int ctrl,
/* Determine what kind of file it is. */
#ifndef PATH_MAX
- if ( ( nslen <= 0 ) || ( ndlen <= 0) )
+ nslen = slen + strlen(Dir->d_name) + 2;
+
+ if (nslen <= 0)
return PAM_BUF_ERR;
- nslen = slen + strlen(Dir->d_name) + 2;
-
if ( (newsource = malloc(nslen)) == NULL )
return PAM_BUF_ERR;
@@ -266,7 +266,10 @@ static int create_homedir(pam_handle_t * pamh, int ctrl,
#ifndef PATH_MAX
ndlen = dlen + strlen(Dir->d_name)+2;
- if ( (newdest = (int *) malloc(ndlen)) == NULL ) {
+ if (ndlen <= 0)
+ return PAM_BUF_ERR;
+
+ if ( (newdest = malloc(ndlen)) == NULL ) {
free(newsource);
return PAM_BUF_ERR;
}