aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJane Smith <thebugfixers@pm.me>2026-07-21 19:45:25 +0000
committerBojan Novković <bnovkov@FreeBSD.org>2026-07-21 19:50:11 +0000
commit9724f3f8974957d2cd15f6b796c347ca50250954 (patch)
treecae7987776009b8a13a4484bea490f2b14af67fa
parentba583f0c2d63f03c834047e48a69095a86a71589 (diff)
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
-rw-r--r--bin/cat/cat.c3
1 files changed, 2 insertions, 1 deletions
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);
}