TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Don't trust comments

58 pointsby xx_nsover 3 years ago

12 comments

throw10920over 3 years ago
Except you can&#x27;t trust function names either.<p>Remember the NSO iMessage exploit?[1] <i>copyGifFromPath</i> didn&#x27;t really copy the GIF from the path.<p>At some point, you <i>do</i> have to trust that the kernel API&#x27;s documentation (or whatever) is correct[2], simply because it&#x27;s physically impossible for you to exhaustively verify that each piece of software you use (transitively) has correct documentation and consistent semantics. That doesn&#x27;t mean that you shouldn&#x27;t audit third-party code, do code reviews, write tests, fuzz your code, and use static analysis and formal methods - in fact, you should do <i>all</i> of those things, if you can.<p>But, &quot;don&#x27;t trust comments&quot; is a gross oversimplification. Perhaps &quot;trust, but verify&quot; is a better pithy saying.<p>[1] <a href="https:&#x2F;&#x2F;googleprojectzero.blogspot.com&#x2F;2021&#x2F;12&#x2F;a-deep-dive-into-nso-zero-click.html" rel="nofollow">https:&#x2F;&#x2F;googleprojectzero.blogspot.com&#x2F;2021&#x2F;12&#x2F;a-deep-dive-i...</a><p>[2] technically, if you did all of the above things, or found other people that did them, then you wouldn&#x27;t have to trust documentation - but the vast majority of the time, most of the software you encounter will <i>not</i> have been thoroughly audited, tested, and fuzzed, with a nice formal specification
评论 #30185435 未加载
评论 #30186534 未加载
评论 #30184795 未加载
nerdponxover 3 years ago
Can someone help me understand what actually happened here? As far as I can gather, the comment in the code wasn&#x27;t a lie, but the overall system was complicated enough that there <i>was</i> a way for the thing-that-shouldn&#x27;t-happen to happen anyway. So the docs weren&#x27;t wrong, but there was a bug in the code that led to incorrect behavior that deviated from the docs.<p>Or am I misunderstanding something?
评论 #30190316 未加载
SahAssarover 3 years ago
Comments state intent, code states reality. If those do not match one of them needs to change.<p>When it comes to security no one should trust that intent matches reality.
wahernover 3 years ago
Thus the hacker refrain, &quot;lies, damned lies, and comments&quot;, for which oddly I&#x27;m unable to find any examples despite having seen it recited several times over the years. In fact, I believe I came across that rephrasing before learning of Twain&#x27;s famous original. I always found it a more pithy justification for why source code comments should only explain why, not how or what.
monetusover 3 years ago
4 days between notification and propagation of the fix. Thank you for poking around OP. Sanitizing your inputs isn&#x27;t always simple.
评论 #30190335 未加载
hinkleyover 3 years ago
I don’t want comments, I want <i>commentary</i>. Every time I’m confidently wrong in a commit message - anything from the wrong bug ID to declaring victory prematurely - I wish I could go modify or amend it.<p>Commits need to be in a separate version tree from their commit messages.
spicybrightover 3 years ago
I kind of wish there was a verifier for function&#x2F;statement comments to flag inaccurate comments (besides interface descriptions + general comment at the top of a function.)<p>Sort of a combination of a reverse github auto-pilot metric and checking how old a comment is based on it&#x27;s surrounding code.<p>You could even syntax highlight based on how accurate it thinks it is like how down voted HN comments fade out.
评论 #30186746 未加载
评论 #30184605 未加载
roylezover 3 years ago
Yes, rst is more powerful. So powerful that it can cause CVE.
longivitateover 3 years ago
Especially this one.
评论 #30184122 未加载
zatarcover 3 years ago
Don&#x27;t trust this comment.
nathiasover 3 years ago
trust but verify
xwdvover 3 years ago
You can definitely trust comments on Hackernews more than other sources such as Reddit.
评论 #30186429 未加载