fdopen return value is not checked.
fp = fdopen(fd, "r"); cook_cat(fp);
fix: check fp == NULL and handle the error.
Differential D57741
NULL pointer dereference in cat Authored by thebugfixers_pm.me on Jun 22 2026, 12:08 PM. Tags None Referenced Files
Details
fdopen return value is not checked. fp = fdopen(fd, "r"); cook_cat(fp); fix: check fp == NULL and handle the error.
Diff Detail
Event Timeline
Comment Actions Why was this review closed? The issue wasn't resolved in the meantime and I see no reason not to land this. Comment Actions 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. Comment Actions I hope that wasn't my local comment which isn't POSIX, but is widely implemented since it does provide more safety than globals. Comment Actions 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. Comment Actions 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). | ||||||||||||||||||||||||||||||||||||||