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.

Results of the 2015 Underhanded C Contest

210 pointsby r4umover 9 years ago

9 comments

makomkover 9 years ago
There&#x27;s an interesting subtlety mentioned in the author&#x27;s explanation <a href="http:&#x2F;&#x2F;www.linusakesson.net&#x2F;programming&#x2F;underhanded&#x2F;2015-spoilers.pdf" rel="nofollow">http:&#x2F;&#x2F;www.linusakesson.net&#x2F;programming&#x2F;underhanded&#x2F;2015-spo...</a> that doesn&#x27;t seem to be mentioned here: the preprocessing had to be carefully designed because the squashing also amplifies any residual noise, so if that wasn&#x27;t thoroughly removed the comparison would fail because it&#x27;d mostly be comparing noise rather than signal. While the type confusion is the only suspicious thing, the rest of the code did have to be crafted to make it work, it&#x27;s just that the other changes are reasonable and non-suspicious.
saucetenutoover 9 years ago
I think this is my favorite Underhanded C submission ever. One simple ambiguity, applied with breathtaking precision and effectiveness. Puts me in mind of an old essay of Zed&#x27;s: <a href="http:&#x2F;&#x2F;zedshaw.com&#x2F;archive&#x2F;the-master-the-expert-the-programmer&#x2F;" rel="nofollow">http:&#x2F;&#x2F;zedshaw.com&#x2F;archive&#x2F;the-master-the-expert-the-program...</a>
评论 #11033753 未加载
评论 #11036205 未加载
评论 #11037652 未加载
blaze33over 9 years ago
And if, like me, you didn&#x27;t knew what this contest was about, the explanation is one click away [1]:<p>&quot;a competition that challenges coders to solve a simple data processing problem by writing innocent-looking C code that is as readable, clear, and seemingly trustworthy as possible, yet covertly implements a malicious function.&quot;<p>[1] <a href="http:&#x2F;&#x2F;underhanded-c.org&#x2F;_page_id_5.html" rel="nofollow">http:&#x2F;&#x2F;underhanded-c.org&#x2F;_page_id_5.html</a>
userbinatorover 9 years ago
The winning entry reminds me of Linus (Torvalds)&#x27; viewpoint on typedefs: <a href="http:&#x2F;&#x2F;yarchive.net&#x2F;comp&#x2F;linux&#x2F;typedefs.html" rel="nofollow">http:&#x2F;&#x2F;yarchive.net&#x2F;comp&#x2F;linux&#x2F;typedefs.html</a><p>Those for whom the name Linus <i>Åkesson</i> is unfamiliar are highly encouraged to visit his site at <a href="http:&#x2F;&#x2F;www.linusakesson.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.linusakesson.net&#x2F;</a> --- he has a lot of other interesting articles on programming and the demoscene.
评论 #11033421 未加载
评论 #11034622 未加载
评论 #11038068 未加载
评论 #11033640 未加载
Kiroover 9 years ago
Here&#x27;s Linus in a completely different but awesome context: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=m1pchpDD5EU" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=m1pchpDD5EU</a>
asgfoiover 9 years ago
I wonder how many of them would be caught using a very strict compiler flag regime.<p>For the winner, perhaps the gcc flag, <i>-Wmissing-prototypes</i> would catch it?
评论 #11033231 未加载
72deluxeover 9 years ago
This is really great!<p>Reading through the source made me look twice though, as I am used to writing C++ so seeing variables defined but not initialised, non-const array starting points as parameters with a separate length parameter (instead of just a reference to a container or a const reference to enforce read-only nature), memcpy instead of copy constructors or copy assignment operators.<p>Basically, it made me realise how impossible I would find it to write good C!<p>Really clever entry though, very impressive. I spotted all the issues I mentioned above, looking for mistakes in them and completely missing the actual problem.
评论 #11033008 未加载
nkurzover 9 years ago
Beautiful. I&#x27;d just looked up float_t, and realized that typedef&#x27;ing it to double was almost certainly a &#x27;tell&#x27;, but I still failed to spot the failure to include the header.<p>I presumed it was simply going to try to slip in a &#x27;float&#x27; for a &#x27;float_t&#x27; and hope it wasn&#x27;t noticed, although it seemed unlikely to be a winning strategy.<p>One other thing that seemed odd was the continued use &#x27;double&#x27; after the typedef. I wonder if there&#x27;s a way to make it work where all the usages are replaced by &#x27;float_t&#x27;.
评论 #11035693 未加载
ibottyover 9 years ago
here is the blog entry of linux akesson, the winner about his entry. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;edit?id=11032712" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;edit?id=11032712</a>
评论 #11032960 未加载