=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tmux.c,v retrieving revision 1.207 retrieving revision 1.208 diff -c -r1.207 -r1.208 *** src/usr.bin/tmux/tmux.c 2021/06/10 07:52:29 1.207 --- src/usr.bin/tmux/tmux.c 2021/07/06 08:26:00 1.208 *************** *** 1,4 **** ! /* $OpenBSD: tmux.c,v 1.207 2021/06/10 07:52:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tmux.c,v 1.208 2021/07/06 08:26:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 211,226 **** free(paths); xasprintf(&base, "%s/tmux-%ld", path, (long)uid); ! if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) goto fail; ! if (lstat(base, &sb) != 0) goto fail; if (!S_ISDIR(sb.st_mode)) { ! errno = ENOTDIR; goto fail; } if (sb.st_uid != uid || (sb.st_mode & S_IRWXO) != 0) { ! errno = EACCES; goto fail; } xasprintf(&path, "%s/%s", base, label); --- 211,232 ---- free(paths); xasprintf(&base, "%s/tmux-%ld", path, (long)uid); ! if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) { ! xasprintf(cause, "couldn't create directory %s (%s)", base, ! strerror(errno)); goto fail; ! } ! if (lstat(base, &sb) != 0) { ! xasprintf(cause, "couldn't read directory %s (%s)", base, ! strerror(errno)); goto fail; + } if (!S_ISDIR(sb.st_mode)) { ! xasprintf(cause, "%s is not a directory", base); goto fail; } if (sb.st_uid != uid || (sb.st_mode & S_IRWXO) != 0) { ! xasprintf(cause, "directory %s has unsafe permissions", base); goto fail; } xasprintf(&path, "%s/%s", base, label); *************** *** 228,234 **** return (path); fail: - xasprintf(cause, "error creating %s (%s)", base, strerror(errno)); free(base); return (NULL); } --- 234,239 ----