* Use our linked list to remember this directory's true ACL setting so
* we may set it correctly at the tail end of the account creation.
*/
- new_dir = (struct uss_subdir *)malloc(sizeof(struct uss_subdir));
+ new_dir = malloc(sizeof(struct uss_subdir));
new_dir->previous = uss_currentDir;
- new_dir->path = (char *)malloc(strlen(a_path) + 1);
- strcpy(new_dir->path, a_path);
- new_dir->finalACL = (char *)malloc(strlen(a_access) + 1);
- strcpy(new_dir->finalACL, a_access);
+ new_dir->path = strdup(a_path);
+ new_dir->finalACL = strdup(a_access);
uss_currentDir = new_dir;
/*
int fd1, fd2;
char buf[BUFSIZ];
- int cnt, rc;
+ int rcnt, wcnt = -1, rc;
umask(0);
fd1 = open(a_to, O_EXCL | O_CREAT | O_WRONLY, a_mode);
close(fd1);
return (1);
}
- while ((cnt = read(fd2, buf, BUFSIZ)) == BUFSIZ)
- write(fd1, buf, cnt);
-
- write(fd1, buf, cnt);
+ do {
+ rcnt = read(fd2, buf, BUFSIZ);
+ if (rcnt == -1)
+ break;
+ wcnt = write(fd1, buf, rcnt);
+ } while (rcnt == BUFSIZ && rcnt == wcnt);
+ if (rcnt == -1 || wcnt != rcnt) {
+ uss_procs_PrintErr(line, "read/write error to %s\n", a_to);
+ close(fd1);
+ close(fd2);
+ return (1);
+ }
rc = close(fd1);
if (rc) {
uss_procs_PrintErr(line, "Failed to close '%s' %s\n", a_to,
return (1);
}
}
- write(fd, a_s, strlen(a_s));
- write(fd, "\n", 1);
+ if (write(fd, a_s, strlen(a_s)) != strlen(a_s) ||
+ write(fd, "\n", 1) != 1) {
+ uss_procs_PrintErr(line, "Short write to '%s'\n", a_f);
+ close(fd);
+ return (1);
+ }
if (close(fd)) {
uss_procs_PrintErr(line, "Failed to close '%s': %s\n", a_f,
strerror(errno));
int i, count, MinIndex = 0, mina = 10000;
struct dirent *dp;
DIR *dirp;
- char dirname[300];
+ char dirname[301];
if (uss_NumGroups == 0) {
fprintf(stderr, "%s: No choice yet given to replace $AUTO\n",
* each and pick the minimum.
*/
for (i = 0; i < uss_NumGroups; i++) {
- sprintf(dirname, "%s/%s", cd, uss_DirPool[i]);
+ snprintf(dirname, sizeof(dirname), "%s/%s", cd, uss_DirPool[i]);
if ((dirp = opendir(dirname)) == NULL) {
if (errno != ENOTDIR)
fprintf(stderr,