Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by harrytuttle on Thursday September 19, 2013 @09:27AM
(#6411432)
What compiler flag is that? Genuinely interested. Wall,pedantic,ansi don't trigger it. I've tried the following and I don't get a warning or error:
$ cat test2.c
int main(int argc, char *argv[]) {
if (argc = 0)
return 1;
return 0;
}
$ make test
cc -Wall -ansi -pedantic test.c -o test
GCC version: gcc version 4.7.2 (Debian 4.7.2-5)
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by huhtenberg on Thursday September 19, 2013 @09:31AM
(#6411457)
huh@px:/tmp$ cat a.c
int main(int argc, char *argv[]) {
if (argc = 0)
return 1;
return 0;
}
huh@px:/tmp$ gcc -Wall a.c
a.c: In function 'main':
a.c:2: warning: suggest parentheses around assignment used as truth value
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by harrytuttle on Thursday September 19, 2013 @09:39AM
(#6411493)
Doesn't do that for me - what GCC ver and environment. Very odd! Digging in docs. Thanks for info.
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by huhtenberg on Thursday September 19, 2013 @09:43AM
(#6411523)
It's some old-ish Debian on x86. GCC is 4.3.2.
But this is a such commonly-recognized pitfall that I actually don't know a single modern production compiler that does not generate this warning.
(edit) Just checked 4.7.1 and it generates the warning.
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by harrytuttle on Thursday September 19, 2013 @10:10AM
(#6411702)
Thanks. I think this must be a config issue on this box. It makes me wonder what other warnings it is not telling me about.
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by detrino on Thursday September 19, 2013 @01:16PM
(#6412903)
Notice that you cat test2.c and then compile test.c.
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by harrytuttle on Thursday September 19, 2013 @02:07PM
(#6413223)
Well spotted! Thanks for pointing this out!
I will now go and hit myself with a LART for a bit to remember not to do that again.
Re:Thwarted Linux backdoor hints at smarter hacks (2003)
by btilly on Thursday September 19, 2013 @10:03AM
(#6411655)
However the same issue happens in a lot of C-like languages, and not all of them have compilers that inform you of errors. But the habit works in all of them.
There are two different ways to catch this class of bug. Both have value.
I'd much rather go that way than write code that reads less like a human wrote it.