git: 75d74cc26f55 - stable/15 - cat: Fix a NULL pointer dereference

Bojan Novković <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.devel.stable.scm
Message-ID <[email protected]>
The branch stable/15 has been updated by bnovkov:

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

commit 75d74cc26f5527cba244112cfe3cfbffd31e987b
Author:     Jane Smith <[email protected]>
AuthorDate: 2026-07-21 19:45:25 +0000
Commit:     Bojan Novković <[email protected]>
CommitDate: 2026-08-10 16:04:32 +0000

    cat: Fix a NULL pointer dereference
    
    Check the `fdopen` return value before calling `cook_cat`.
    
    Reviewed by:    markj, bnovkov
    Differential Revision:  https://reviews.freebsd.org/D57741
    MFC after:      1 week
    
    (cherry picked from commit 9724f3f8974957d2cd15f6b796c347ca50250954)
---
 bin/cat/cat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index c4c04fb3fff6..8c10faf7cff9 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -259,7 +259,8 @@ scanfiles(char *argv[], int cooked __unused)
 			if (fd == STDIN_FILENO)
 				cook_cat(stdin);
 			else {
-				fp = fdopen(fd, "r");
+				if ((fp = fdopen(fd, "r")) == NULL)
+					err(1, "fdopen");
 				cook_cat(fp);
 				fclose(fp);
 			}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.