policycoreutils: setfiles: Fix potential crash using dereferenced ftsent

If fts_read() fails for any reason ftsent will be NULL.  Previously we
would have reported the error and then continued processing.  Now we
report the error and stop using the NULL pointer.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Dan Walsh 2011-08-09 09:53:49 -04:00 committed by Eric Paris
parent a2db3f2df8
commit f23e078018

View File

@ -318,11 +318,16 @@ static int process_one(char *name, int recurse_this_path)
ftsent = fts_read(fts_handle);
if (ftsent != NULL) {
/* Keep the inode of the first one. */
dev_num = ftsent->fts_statp->st_dev;
if (ftsent == NULL) {
fprintf(stderr,
"%s: error while labeling %s: %s\n",
r_opts->progname, namelist[0], strerror(errno));
goto err;
}
/* Keep the inode of the first one. */
dev_num = ftsent->fts_statp->st_dev;
do {
rc = 0;
/* Skip the post order nodes. */