makefs: Handle missing link keyword in mtree spec

PR:		241178
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/850

(cherry picked from commit d26c1a0f8b)
(cherry picked from commit be31bd5989)
This commit is contained in:
Stéphane Rochoy 2023-09-21 09:14:20 +02:00 committed by Ed Maste
parent d99a15bf6f
commit d8d0ecd973

View file

@ -740,7 +740,10 @@ read_mtree_keywords(FILE *fp, fsnode *node)
type = S_IFREG;
} else if (node->type != 0) {
type = node->type;
if (type == S_IFREG) {
if (type == S_IFLNK && node->symlink == NULL) {
mtree_error("%s: link type requires link keyword", node->name);
return (0);
} else if (type == S_IFREG) {
/* the named path is the default contents */
node->contents = mtree_file_path(node);
}