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 | |
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 ..
-rw-r--r-- | usr/src/cmd/chmod/chmod.c | 11 | ||||
-rw-r--r-- | usr/src/cmd/chown/chown.c | 13 |
2 files changed, 13 insertions, 11 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); diff --git a/usr/src/cmd/chown/chown.c b/usr/src/cmd/chown/chown.c index 876f4e554b..d5912c9aa3 100644 --- a/usr/src/cmd/chown/chown.c +++ b/usr/src/cmd/chown/chown.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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -376,9 +375,11 @@ chownr(char *dir, uid_t uid, gid_t gid) status += Perror(dir); return; } - dp = readdir(dirp); - dp = readdir(dirp); /* read "." and ".." */ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { + if (strcmp(dp->d_name, ".") == 0 || /* skip . and .. */ + strcmp(dp->d_name, "..") == 0) { + continue; + } if (lstat(dp->d_name, &st) < 0) { status += Perror(dp->d_name); continue; |