From a46be6867a41614389fb3edd6039446c21a9a6f6 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Wed, 23 Jan 2019 13:33:40 +0100 Subject: [PATCH] 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 --- bin/xbps-create/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index 2c211215..6ec05aca 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -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: