diff options
author | casper <none@none> | 2006-03-10 13:20:29 -0800 |
---|---|---|
committer | casper <none@none> | 2006-03-10 13:20:29 -0800 |
commit | c4518760d2eafcdb3ae533ddb846eae71a3dbc57 (patch) | |
tree | 206854fa85bcd70c0d9c2d3964e870cd4c02bb3d /usr/src/cmd/chmod/chmod.c | |
parent | 97682a823d4ed139a3af5f6e1385b1de019d55d3 (diff) | |
download | illumos-joyent-c4518760d2eafcdb3ae533ddb846eae71a3dbc57.tar.gz |
4171523 chmod/chown -R crash if the two first entries of a directory are not . and ..
Diffstat (limited to 'usr/src/cmd/chmod/chmod.c')
-rw-r--r-- | usr/src/cmd/chmod/chmod.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr/src/cmd/chmod/chmod.c b/usr/src/cmd/chmod/chmod.c index 8be3ff9373..c1efadbaac 100644 --- a/usr/src/cmd/chmod/chmod.c +++ b/usr/src/cmd/chmod/chmod.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -275,8 +274,6 @@ chmodr(char *dir, char *path, mode_t mode, mode_t umsk, acl_args_t *aclp) errmsg(2, 0, "%s\n", strerror(errno)); return (1); } - dp = readdir(dirp); - dp = readdir(dirp); /* read "." and ".." */ ecode = 0; /* @@ -291,6 +288,10 @@ chmodr(char *dir, char *path, mode_t mode, mode_t umsk, acl_args_t *aclp) (void) strcat(parentdir, "/"); for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { + if (strcmp(dp->d_name, ".") == 0 || /* skip . and .. */ + strcmp(dp->d_name, "..") == 0) { + continue; + } (void) strcpy(currdir, parentdir); (void) strcat(currdir, dp->d_name); ecode += dochmod(dp->d_name, currdir, umsk, aclp); |