Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140126401
D44810.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44810.diff
View Options
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -371,8 +371,8 @@
err(EX_OSERR, "%s vanished", to_name);
if (S_ISLNK(to_sb.st_mode)) {
if (argc != 2) {
- errno = ENOTDIR;
- err(EX_USAGE, "%s", to_name);
+ errc(EX_CANTCREAT, ENOTDIR, "%s",
+ to_name);
}
install(*argv, to_name, fset, iflags);
exit(EX_OK);
@@ -398,14 +398,13 @@
if (!no_target && !dolink) {
if (stat(*argv, &from_sb))
err(EX_OSERR, "%s", *argv);
- if (!S_ISREG(to_sb.st_mode)) {
- errno = EFTYPE;
- err(EX_OSERR, "%s", to_name);
- }
+ if (!S_ISREG(to_sb.st_mode))
+ errc(EX_CANTCREAT, EFTYPE, "%s", to_name);
if (to_sb.st_dev == from_sb.st_dev &&
- to_sb.st_ino == from_sb.st_ino)
- errx(EX_USAGE,
- "%s and %s are the same file", *argv, to_name);
+ to_sb.st_ino == from_sb.st_ino) {
+ errx(EX_USAGE, "%s and %s are the same file",
+ *argv, to_name);
+ }
}
install(*argv, to_name, fset, iflags);
exit(EX_OK);
@@ -749,10 +748,10 @@
if (realpath(dir, dst) == NULL)
err(EX_OSERR, "%s: realpath", dir);
if (strcmp(dst, "/") != 0 &&
- strlcat(dst, "/", sizeof(dst)) > sizeof(dst))
+ strlcat(dst, "/", sizeof(dst)) >= sizeof(dst))
errx(1, "resolved pathname too long");
}
- if (strlcat(dst, base, sizeof(dst)) > sizeof(dst))
+ if (strlcat(dst, base, sizeof(dst)) >= sizeof(dst))
errx(1, "resolved pathname too long");
free(to_name_copy);
@@ -819,10 +818,8 @@
if (!dolink) {
if (stat(from_name, &from_sb))
err(EX_OSERR, "%s", from_name);
- if (!S_ISREG(from_sb.st_mode)) {
- errno = EFTYPE;
- err(EX_OSERR, "%s", from_name);
- }
+ if (!S_ISREG(from_sb.st_mode))
+ errc(EX_OSERR, EFTYPE, "%s", from_name);
}
/* Build the target path. */
if (flags & DIRECTORY) {
@@ -846,11 +843,8 @@
return;
}
- if (target && !S_ISREG(to_sb.st_mode) && !S_ISLNK(to_sb.st_mode)) {
- errno = EFTYPE;
- warn("%s", to_name);
- return;
- }
+ if (target && !S_ISREG(to_sb.st_mode) && !S_ISLNK(to_sb.st_mode))
+ errc(EX_CANTCREAT, EFTYPE, "%s", to_name);
if (!devnull && (from_fd = open(from_name, O_RDONLY, 0)) < 0)
err(EX_OSERR, "%s", from_name);
@@ -1194,9 +1188,9 @@
DIGEST_CTX ctx;
/* Rewind file descriptors. */
- if (lseek(from_fd, (off_t)0, SEEK_SET) == (off_t)-1)
+ if (lseek(from_fd, 0, SEEK_SET) < 0)
err(EX_OSERR, "lseek: %s", from_name);
- if (lseek(to_fd, (off_t)0, SEEK_SET) == (off_t)-1)
+ if (lseek(to_fd, 0, SEEK_SET) < 0)
err(EX_OSERR, "lseek: %s", to_name);
#ifndef BOOTSTRAP_XINSTALL
@@ -1204,7 +1198,7 @@
if (digesttype == DIGEST_NONE) {
do {
ret = copy_file_range(from_fd, NULL, to_fd, NULL,
- SSIZE_MAX, 0);
+ (size_t)size, 0);
} while (ret > 0);
if (ret == 0)
goto done;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 2:38 PM (12 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27114352
Default Alt Text
D44810.diff (2 KB)
Attached To
Mode
D44810: install: Assorted nitpickery.
Attached
Detach File
Event Timeline
Log In to Comment