第二届Underhanded C比赛开始 [英] 2nd Underhanded C Contest Begins

查看:47
本文介绍了第二届Underhanded C比赛开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第二场Underhanded C比赛今天刚刚开幕,并将持续到7月4日
。该奖项是ThinkGeek的礼品券。


对象是编写欺骗性的C代码,代码可以做某些事情

恶意,但看起来无辜且简单到足以通过一个粗略的

考试来源。


去年的比赛是写一个图像处理程序

秘密在它创建的图像中嵌入指纹。今年的b $ b b挑战是编写一个在一个操作系统上运行良好的C代码,但在竞争对手的操作系统上神秘地慢慢地b / b



-

古老的乡村音乐明星不会死 - 他们只是被放进棺材里埋葬了

在地上然后没有人再次见到他们。

- 猫和女孩

The second Underhanded C contest just opened today, and will run until
July 4th. The Prize is a ThinkGeek gift certificate.

The object is to write deceptive C code, code that does something
malicious but looks innocent and simple enough to pass a cursory
examination of the source.

Last year''s contest was to write an image processing routine that
covertly embedds fingerprints in the images it creates. This year''s
challenge is to write C code that runs fine on one OS but mysteriously
slowly on a competing OS.

--
"Old country music stars don''t die -- they just get put in a coffin and buried
in the ground and then no one sees them ever again."
--Cat and Girl

推荐答案

Xcott Craver< ca * @ BrainHz。 COM>写道:
Xcott Craver <ca*@B-r-a-i-n-H-z.com> wrote:
今天刚刚开幕的第二场Underhanded C比赛将持续到7月4日。奖品是ThinkGeek的礼品券。
The second Underhanded C contest just opened today, and will run until
July 4th. The Prize is a ThinkGeek gift certificate.




Dang-nabbit,我忘记了网址: http://www.brainhz.com/underhanded/

-

古老的乡村音乐明星不会死 - 他们只是被放入棺材并埋在地下,然后没有人再看到它们了。

--Cat and Girl



Dang-nabbit, I forgot the URL: http://www.brainhz.com/underhanded/

--
"Old country music stars don''t die -- they just get put in a coffin and buried
in the ground and then no one sees them ever again."
--Cat and Girl


Xcott Craver写道:
Xcott Craver wrote:
今年的挑战是编写C代码在一个操作系统上运行良好,但在竞争的操作系统上神秘地慢慢运行。
This year''s
challenge is to write C code that runs fine on one OS but mysteriously
slowly on a competing OS.




void setnormalcount(uint8 * count){

count = 3;

}


const uint32 count = 0;

#ifdef NDEBUG

setnormalcount (& count);

#endif


while(count--){

do_some_normal_task();

}



void setnormalcount(uint8 *count) {
count = 3;
}

const uint32 count = 0;
#ifdef NDEBUG
setnormalcount(&count);
#endif

while(count--) {
do_some_normal_task();
}




Sebastian Gottschalk写道:

Sebastian Gottschalk wrote:
Xcott Craver写道:
Xcott Craver wrote:
今年的挑战是写一个在一个操作系统上运行正常的C代码但是在一个竞争的操作系统上慢慢地神秘地消失了。
void setnormalcount(uint8 * count){
count = 3;
}
This year''s
challenge is to write C code that runs fine on one OS but mysteriously
slowly on a competing OS.
void setnormalcount(uint8 *count) {
count = 3;
}




应该是* count = 3;

const uint32 count = 0;
#ifdef NDEBUG
setnormalcount(& count);


这将警告。

#endif


假设count = 0可能有效在这一点上,编译器

可以优化这个循环。

while(count--){
do_some_normal_task();
}



That should be *count = 3;
const uint32 count = 0;
#ifdef NDEBUG
setnormalcount(&count);
This will warning out.
#endif
It''s probably valid to assume count=0 at this point and the compiler
may optimize out this loop.
while(count--) {
do_some_normal_task();
}




GCC 3.4.6甚至不编译。它抱怨说递减

计数是无效的。


是的,GCC会允许你覆盖''count'',但假设它为零。


例如


void p(unsigned char * t){* t = 3; }

const unsigned r = 0;

void q(void){p(& r); if(r)printf(" Whoa!\ n"); }


产生[在我的amd64上]


p:

..LFB2:

movb



GCC 3.4.6 won''t even compile this. It complains that decrementing
count is invalid.

And yes, GCC will allow you to overwrite ''count'' but assumes it''s zero.

For instance

void p(unsigned char *t) { *t = 3; }
const unsigned r = 0;
void q(void) { p(&r); if (r) printf("Whoa!\n"); }

produces [on my amd64]

p:
..LFB2:
movb


这篇关于第二届Underhanded C比赛开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆