Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103120230
D27184.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D27184.diff
View Options
Index: head/bin/chflags/chflags.c
===================================================================
--- head/bin/chflags/chflags.c
+++ head/bin/chflags/chflags.c
@@ -163,7 +163,7 @@
if ((ftsp = fts_open(++argv, fts_options , 0)) == NULL)
err(1, NULL);
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ for (rval = 0; errno = 0, (p = fts_read(ftsp)) != NULL;) {
int atflag;
if ((fts_options & FTS_LOGICAL) ||
Index: head/bin/chmod/chmod.c
===================================================================
--- head/bin/chmod/chmod.c
+++ head/bin/chmod/chmod.c
@@ -164,7 +164,7 @@
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, "fts_open");
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ for (rval = 0; errno = 0, (p = fts_read(ftsp)) != NULL;) {
int atflag;
if ((fts_options & FTS_LOGICAL) ||
Index: head/bin/cp/cp.c
===================================================================
--- head/bin/cp/cp.c
+++ head/bin/cp/cp.c
@@ -282,7 +282,8 @@
if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL)
err(1, "fts_open");
- for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) {
+ for (badcp = rval = 0; errno = 0, (curr = fts_read(ftsp)) != NULL;
+ badcp = 0) {
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR:
Index: head/bin/ls/ls.c
===================================================================
--- head/bin/ls/ls.c
+++ head/bin/ls/ls.c
@@ -645,7 +645,7 @@
ch_options = !f_recursive && !f_label &&
options & FTS_NOSTAT ? FTS_NAMEONLY : 0;
- while ((p = fts_read(ftsp)) != NULL)
+ while (errno = 0, (p = fts_read(ftsp)) != NULL)
switch (p->fts_info) {
case FTS_DC:
warnx("%s: directory causes a cycle", p->fts_name);
Index: head/bin/rm/rm.c
===================================================================
--- head/bin/rm/rm.c
+++ head/bin/rm/rm.c
@@ -207,7 +207,7 @@
return;
err(1, "fts_open");
}
- while ((p = fts_read(fts)) != NULL) {
+ while (errno = 0, (p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
if (!fflag || p->fts_errno != ENOENT) {
Index: head/bin/setfacl/setfacl.c
===================================================================
--- head/bin/setfacl/setfacl.c
+++ head/bin/setfacl/setfacl.c
@@ -498,8 +498,10 @@
/* Open all files. */
if ((ftsp = fts_open(files_list, fts_options | FTS_NOSTAT, 0)) == NULL)
err(1, "fts_open");
- while ((file = fts_read(ftsp)) != NULL)
+ while (errno = 0, (file = fts_read(ftsp)) != NULL)
carried_error += handle_file(ftsp, file);
+ if (errno != 0)
+ err(1, "fts_read");
return (carried_error);
}
Index: head/contrib/mtree/create.c
===================================================================
--- head/contrib/mtree/create.c
+++ head/contrib/mtree/create.c
@@ -129,7 +129,7 @@
if ((t = fts_open(argv, ftsoptions, dcmp)) == NULL)
mtree_err("fts_open: %s", strerror(errno));
- while ((p = fts_read(t)) != NULL) {
+ while (errno = 0, (p = fts_read(t)) != NULL) {
if (jflag)
indent = p->fts_level * 4;
if (check_excludes(p->fts_name, p->fts_path)) {
@@ -173,6 +173,8 @@
}
}
+ if (errno != 0)
+ mtree_err("fts_read: %s", strerror(errno));
fts_close(t);
if (sflag && keys & F_CKSUM)
mtree_err("%s checksum: %u", fullpath, crc_total);
Index: head/contrib/mtree/verify.c
===================================================================
--- head/contrib/mtree/verify.c
+++ head/contrib/mtree/verify.c
@@ -90,7 +90,7 @@
mtree_err("fts_open: %s", strerror(errno));
level = root;
specdepth = rval = 0;
- while ((p = fts_read(t)) != NULL) {
+ while (errno = 0, (p = fts_read(t)) != NULL) {
if (check_excludes(p->fts_name, p->fts_path)) {
fts_set(t, p, FTS_SKIP);
continue;
@@ -160,6 +160,8 @@
}
fts_set(t, p, FTS_SKIP);
}
+ if (errno != 0)
+ mtree_err("fts_read: %s", strerror(errno));
fts_close(t);
if (sflag)
warnx("%s checksum: %u", fullpath, crc_total);
Index: head/usr.bin/du/du.c
===================================================================
--- head/usr.bin/du/du.c
+++ head/usr.bin/du/du.c
@@ -268,7 +268,7 @@
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
err(1, "fts_open");
- while ((p = fts_read(fts)) != NULL) {
+ while (errno = 0, (p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_D: /* Ignore. */
if (ignorep(p))
Index: head/usr.bin/grep/util.c
===================================================================
--- head/usr.bin/grep/util.c
+++ head/usr.bin/grep/util.c
@@ -154,7 +154,7 @@
__DECONST(char * const *, wd) : argv, fts_flags, NULL);
if (fts == NULL)
err(2, "fts_open");
- while ((p = fts_read(fts)) != NULL) {
+ while (errno = 0, (p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
/* FALLTHROUGH */
@@ -187,6 +187,8 @@
break;
}
}
+ if (errno != 0)
+ err(2, "fts_read");
fts_close(fts);
return (matched);
Index: head/usr.bin/gzip/gzip.c
===================================================================
--- head/usr.bin/gzip/gzip.c
+++ head/usr.bin/gzip/gzip.c
@@ -2075,7 +2075,7 @@
return;
}
- while ((entry = fts_read(fts))) {
+ while (errno = 0, (entry = fts_read(fts))) {
switch(entry->fts_info) {
case FTS_D:
case FTS_DP:
@@ -2090,6 +2090,8 @@
handle_file(entry->fts_path, entry->fts_statp);
}
}
+ if (errno != 0)
+ warn("error with fts_read %s", dir);
(void)fts_close(fts);
}
#endif
Index: head/usr.sbin/chown/chown.c
===================================================================
--- head/usr.sbin/chown/chown.c
+++ head/usr.sbin/chown/chown.c
@@ -177,7 +177,7 @@
if ((ftsp = fts_open(++argv, fts_options, NULL)) == NULL)
err(1, NULL);
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ for (rval = 0; errno = 0, (p = fts_read(ftsp)) != NULL;) {
int atflag;
if ((fts_options & FTS_LOGICAL) ||
Index: head/usr.sbin/ckdist/ckdist.c
===================================================================
--- head/usr.sbin/ckdist/ckdist.c
+++ head/usr.sbin/ckdist/ckdist.c
@@ -151,7 +151,7 @@
arg[0] = *argv;
if ((ftsp = fts_open(arg, FTS_LOGICAL, NULL)) == NULL)
err(2, "fts_open");
- while ((f = fts_read(ftsp)) != NULL)
+ while (errno = 0, (f = fts_read(ftsp)) != NULL)
switch (f->fts_info) {
case FTS_DC:
rval = fail(f->fts_path, "Directory causes a cycle");
Index: head/usr.sbin/fmtree/create.c
===================================================================
--- head/usr.sbin/fmtree/create.c
+++ head/usr.sbin/fmtree/create.c
@@ -102,7 +102,7 @@
argv[1] = NULL;
if ((t = fts_open(argv, ftsoptions, dsort)) == NULL)
err(1, "fts_open()");
- while ((p = fts_read(t))) {
+ while (errno = 0, (p = fts_read(t))) {
if (iflag)
indent = p->fts_level * 4;
if (check_excludes(p->fts_name, p->fts_path)) {
@@ -137,6 +137,8 @@
}
}
+ if (errno != 0)
+ err(1, "fts_read()");
(void)fts_close(t);
if (sflag && keys & F_CKSUM)
warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
Index: head/usr.sbin/fmtree/verify.c
===================================================================
--- head/usr.sbin/fmtree/verify.c
+++ head/usr.sbin/fmtree/verify.c
@@ -86,7 +86,7 @@
err(1, "line %d: fts_open", lineno);
level = root;
specdepth = rval = 0;
- while ((p = fts_read(t))) {
+ while (errno = 0, (p = fts_read(t))) {
if (check_excludes(p->fts_name, p->fts_path)) {
fts_set(t, p, FTS_SKIP);
continue;
@@ -149,6 +149,8 @@
}
(void)fts_set(t, p, FTS_SKIP);
}
+ if (errno != 0)
+ err(1, "fts_read()");
(void)fts_close(t);
if (sflag)
warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total);
Index: head/usr.sbin/setfmac/setfmac.c
===================================================================
--- head/usr.sbin/setfmac/setfmac.c
+++ head/usr.sbin/setfmac/setfmac.c
@@ -142,7 +142,7 @@
fts = fts_open(argv, hflag | xflag, NULL);
if (fts == NULL)
err(1, "cannot traverse filesystem%s", argc ? "s" : "");
- while ((ftsent = fts_read(fts)) != NULL) {
+ while (errno = 0, (ftsent = fts_read(fts)) != NULL) {
switch (ftsent->fts_info) {
case FTS_DP: /* skip post-order */
break;
@@ -176,6 +176,8 @@
ftsent->fts_info, ftsent->fts_path);
}
}
+ if (errno != 0)
+ err(1, "fts_read");
fts_close(fts);
exit(0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 6:54 AM (5 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14771721
Default Alt Text
D27184.diff (8 KB)
Attached To
Mode
D27184: fts_read: Handle error from a NULL return better.
Attached
Detach File
Event Timeline
Log In to Comment