git: d26c1a0f8bce - main - makefs: Handle missing link keyword in mtree spec

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Thu, 21 Sep 2023 16:49:19 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=d26c1a0f8bceb6748436fe3fc57bac3ef8179dd3

commit d26c1a0f8bceb6748436fe3fc57bac3ef8179dd3
Author:     Stéphane Rochoy <stephane.rochoy@stormshield.eu>
AuthorDate: 2023-09-21 07:14:20 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-09-21 16:49:11 +0000

    makefs: Handle missing link keyword in mtree spec
    
    PR:             241178
    Reviewed by:    emaste
    MFC after:      3 days
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/850
---
 usr.sbin/makefs/mtree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
index 45588e202542..3e62afbc1137 100644
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -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);
 		}