Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 18 submissions in the queue.

Submission Preview

Link to Story

Results of The Underhanded C Competition 2015

Accepted submission by tonyPick at 2016-02-04 11:05:05
Software

The Underhanded C competition [underhanded-c.org] has just announced the 2015 winner and runners up.

The objective of the competition is to:

write C code that is as readable, clear, innocent and straightforward as possible, and yet it must fail to perform at its apparent function. To be more specific, it should perform some specific underhanded task that will not be detected by examining the source code.

For this particular competition:

two countries agree to build a fissile material detector with an “information barrier”—-essentially a computer program that will take the result of a scan, determine if it matches some reference pattern, and output only a “yes” or “no.”

Your goal is to write the function that compares a test measurement to a reference pattern:

int match( double * test, double * reference, int bins, double threshold )

…where test and reference are 1-dimensional arrays of width bins, that encode a gamma ray spectrum of a test warhead and a reference warhead, respectively. Your detector should output a 1 (“yes”) if these two arrays are sufficiently similar, and 0 (“no”) otherwise; you should use the parameter threshold to adjust the sensitivity of the match.
...
Somehow, match() should return a “yes” even when fissile material is missing, if triggered by certain circumstances that can be engineered by the host country.

The winning entry uses some clever type confusion between double and single precision floats.


Original Submission