xbps-create: reject unhandled files

A segfault in xbps-create(1) was found in:
https://github.com/void-linux/void-packages/pull/7524

xbps-create adds a file type string to the xentry for every file it
finds in `destdir`, files other than symlinks, regular files and
directories weren't handled and resulted in a segfault later when
when processing the xentry structures.

This commit adds checks for sockets and fifos and exits with an
appropriate error message or with a generic error message for every
other unhandled file.

Closes #66
This commit is contained in:
Duncaen 2019-01-23 13:33:40 +01:00
parent 25427fca7d
commit a46be6867a

View File

@ -483,6 +483,15 @@ ftw_cb(const char *fpath, const struct stat *sb, const struct dirent *dir UNUSED
xbps_dictionary_set_cstring_nocopy(fileinfo, "type", "dirs");
xe->type = strdup("dirs");
assert(xe->type);
} else if (S_ISFIFO(sb->st_mode)) {
errno = 0;
die("cannot package fifo %s", fpath);
} else if (S_ISSOCK(sb->st_mode)) {
errno = 0;
die("cannot package socket %s", fpath);
} else {
errno = 0;
die("cannot package %s", fpath);
}
out: