git: be31bd59895e - stable/14 - makefs: Handle missing link keyword in mtree spec

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sun, 24 Sep 2023 13:19:54 UTC
The branch stable/14 has been updated by emaste:

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

commit be31bd59895e57fb7359de870ea3ecc19e3d1ae1
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-24 13:17:43 +0000

    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 d26c1a0f8bceb6748436fe3fc57bac3ef8179dd3)
---
 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);
 		}