Page MenuHomeFreeBSD

NULL pointer dereference in cat
AbandonedPublic

Authored by thebugfixers_pm.me on Jun 22 2026, 12:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 4, 8:31 AM
Unknown Object (File)
Fri, Sep 4, 3:39 AM
Unknown Object (File)
Thu, Sep 3, 7:15 PM
Unknown Object (File)
Thu, Sep 3, 5:20 AM
Unknown Object (File)
Wed, Sep 2, 3:00 PM
Unknown Object (File)
Wed, Sep 2, 12:12 PM
Unknown Object (File)
Wed, Sep 2, 8:32 AM
Unknown Object (File)
Tue, Sep 1, 7:27 PM
Subscribers

Details

Summary

fdopen return value is not checked.

fp = fdopen(fd, "r");
cook_cat(fp);

fix: check fp == NULL and handle the error.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

markj added inline comments.
bin/cat/cat.c
268

This should be handled as a fatal error.

Ignore that last diff (2). My bad. Updated version coming shortly.

thebugfixers_pm.me marked an inline comment as done.

Why was this review closed? The issue wasn't resolved in the meantime and I see no reason not to land this.

Why was this review closed? The issue wasn't resolved in the meantime and I see no reason not to land this.

I cannot remember, but looking at the timestamp, my guess is it was perhaps related to 'politics' I experienced on another diff where I was basically told in no uncertain terms 'its always been this way and we're not changing it' despite the POSIX standards having quite clearly moved on. This is all despite the case that two reviewers were (as far as I could tell) very happy with the concept of the proposed changes subject to minor revision and then I was basically shouted out of the room by the third. I have better things to do with my life than engage in politics, so I abandoned that one and moved on with my life.

Anyway, coming quickly back to your actual question I guess I must have thought at the time that touching cat might also eventually land me unwelcome attention for daring to touch a long-standing binary if they came looking for me on other diffs, so it was quite possibly a pre-emptive abandoning.

Clearly I have no issues with it being landed. If you want to take ownership you're welcome. Equally if you want me to reclaim the revision so it becomes active and can be landed as-is in its present state, I can do that too.

Why was this review closed? The issue wasn't resolved in the meantime and I see no reason not to land this.

I cannot remember, but looking at the timestamp, my guess is it was perhaps related to 'politics' I experienced on another diff where I was basically told in no uncertain terms 'its always been this way and we're not changing it' despite the POSIX standards having quite clearly moved on. This is all despite the case that two reviewers were (as far as I could tell) very happy with the concept of the proposed changes subject to minor revision and then I was basically shouted out of the room by the third. I have better things to do with my life than engage in politics, so I abandoned that one and moved on with my life.

I hope that wasn't my local comment which isn't POSIX, but is widely implemented since it does provide more safety than globals.

In D57741#1340395, @imp wrote:

I hope that wasn't my local comment which isn't POSIX, but is widely implemented since it does provide more safety than globals.

No, you're safe @imp , I just went back and checked, it wasn't you. ;)

If you really want to know, it was des. TL;DR: ziaee and jilles were happy with D57892 subject to various minor tweaks, but then des came along.... just after I had spent time implementing the recommendations from ziaee and jilles, which made me doubly unhappy as I'd effectively just wasted my time.

I only originally mentioned it because of the question from @bnovkov. As I said, I've put the whole saga behind me but will now be more cautious about if/what I suggest diffs for in the future.

Anyway this is all now drifting off topic for this particular diff. So I will stop there.

Anyway, coming quickly back to your actual question I guess I must have thought at the time that touching cat might also eventually land me unwelcome attention for daring to touch a long-standing binary if they came looking for me on other diffs, so it was quite possibly a pre-emptive abandoning.

Understandable, I'm sorry to hear about your bad review experiences.

This patch is very clearly useful so I've already taken the liberty of landing it (rG9724f3f8974).
Thank you again for working on this!