The branch main has been updated by bnovkov:

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

commit 9724f3f8974957d2cd15f6b796c347ca50250954
Author:     Jane Smith <[email protected]>
AuthorDate: 2026-07-21 19:45:25 +0000
Commit:     Bojan Novković <[email protected]>
CommitDate: 2026-07-21 19:50:11 +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
---
 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);
                        }

Reply via email to