| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
lol omigosh frist!!11!!
|
|
So realyl, it doesn't matter if you are logged in.
The || essentially makign it so if you are logged in you can upload, if you are not logged in, you can upload, because in our reality 2+2 does equal 4. Why not do away with the check in it's entirety? You will get the same results. EDIT: Just thought of a reason for this. It is to prevent anyone using one of those really old pentium processors where 2 might become a float and the math error might make 2+2 != 4. {shoots pinkie pie with caffine to watch her spontaneously explode} |
|
I forgot my password, would you clear it?
|
Re: Authenticate or Math
2012-04-04 09:05
•
by
jim
(unregistered)
|
You don't say. |
|
if frist { postcomment("Frist!!>!@!@12!!"); } else { postcomment("Frist!!>!@!@12!!"); }
|
|
In abadabad code throws you
|
|
I'm just looking at the WTF in the text:
I started sifting throw hundreds Should it not be I started sifting through hundreds |
|
Looks like an "always true" clause added in the condition to force the behavior, probably temporarily for debugging purposes.
TRWTF is the lack of comment/TODO/etc. about it and the fact it was checked in. |
|
Big Brother had decreed that your conditional expression not evaluate to true.
Can computers doublethink? |
|
normally if you want to force a true you add "|| true" not a math function. Reminds me of the shirt:
2+2=5 For extremely large values of 2 |
Maybe the original author saw the technique in the log of some generated SQL and thought to himself “Neat! I'll try that myself…” |
Re: Authenticate or Math
2012-04-04 09:19
•
by
The_Assimilator
|
You are correct. TDWTF needs to hire some proofreaders, stat. |
Re: Authenticate or Math
2012-04-04 09:23
•
by
Hello
(unregistered)
|
Thanks KattMan for the explanation! Couldn't have done it without you. |
Since one out of 3 WTFs start this way (in real life, and, typically, here) shouldn't we just have a separate category for them? |
|
It's obviously debug code that either the original developer forgot to take out, or was purposely left in to bypass having to constantly log in. Since it was an unfinished project it's likely the latter and the new guy needs to get off his high horse. In my experience many developers when having to take over a new project will trash the work of the previous generation since it's easier to do than actually having to really learn the architecture.
|
|
Could make sense as a temporary debugging change, to force the login to work while testing.
A distinctive "true" value is easier to remove when testing is done. When it's time to remove the bypass, which would you rather search for: "true" or " || 2+2=4" ? You probably don't want to blindly remove all "true" strings but you can safely search&replace " || 2+2=4" with "". |
Easy. If you're coming from an alternate universe with slightly different physics, we need to know who you are. From this universe, welcome! |
Re: Authenticate or Math
2012-04-04 09:32
•
by
Chopper
(unregistered)
|
Not if you're a banker! |
Re: Authenticate or Math
2012-04-04 09:32
•
by
Another fake Nagesh
(unregistered)
|
|
This remine me level of security here in Abadabad.
|
Re: Authenticate or Math
2012-04-04 09:34
•
by
Jouva
(unregistered)
|
Thanks so much for explaining this! As a programmer I would NEVER have understood programming language logic and feel that such a joke obvious to the visitors of this website needed a full explanation. |
Re: Authenticate or Math
2012-04-04 09:36
•
by
ThingGuy McGuyThing
|
By golly, I think you've solved it. |
|
In my country we frist lern to spel and than we proveread.
|
|
No good, because what if 2 changes so that 2+2 no longer equals 4? Should be "|| 2+2 == 2+2", so even if 2+2 = 6, it will still evaluate correctly.
|
|
Seriously guys, that's like basic optimization knowledge.
Yes, 2+2==4 is always true, but as it is an expression it is not for free. Now if logged_in() is true, 2+2==4 does not have to be evaluated at all, saving valueable processor time. |
|
It's clearly debug code. I on the other hand actually have "where 1 = 1" code in production. And I don't consider it a WTF. When appending various conditions to dynamic sql it's easier to start with a no-op condition and then append all the other conditions starting with "AND" without keeping track of "is this my first condition? no? then throw in and".
|
|
This is obvious not C-based language. Sometime, developer is taking order-of-opeation for granted. Also, evaluation of OR is not treated seme in all language.
|
I wish he hadn't. |
You are all welcome, I have fulfilled my public service for the year, thanks to all of you that listened. |
|
Actually, the code might have a pretty legit reason. In some cases you can not just put "true" into "if" condition if there is "else" branch in the code, the compiler will complain about unreachable code.
Seeing this in the production code kind of sucks though. |
Re: Authenticate or Math
2012-04-04 10:15
•
by
jonny_q
(unregistered)
|
If 2+2==4 is his favorite debugging alias for "true" then it's easier to search for to remove later. It's a built-in todo. Still dumb, but that's the thought process. I've gotten very good as learning to think like the retard I have to clean up after. |
|
Its a valid check that users from other dimensions, where Maths is fundamentally different, from accessing the upload functionality.
|
Using debug code? Pick one from the list above. |
Re: Authenticate or Math
2012-04-04 10:26
•
by
Quicksilver
(unregistered)
|
Or you are living in Airstrip One! |
|
The very first infinite loop I wrote when I was a noob looked like this:
while(6 != 7) I thought I was so clever. |
|
What's in logged_in() ?
A throw perhaps? |
|
I've got it! If the program is being run in an alternate universe, then 2+2 might not equal 4. If this is a case, THEN we check to see if the user is logged in or not.
|
|
Actually it *MAY* matter... perhaps the latest version throws and exception in the if condition when the user is not logged int.
|
|
This is big brother protection.
In case the government decides that 2 + 2 = 5, the code will actually require someone to be logged in. |
Re: Authenticate or Math
2012-04-04 11:11
•
by
Todd Lewis
(unregistered)
|
Which is exactly what's wrong with the whole "try/catch let's pretend we've got objects in our made up computer world" style of programming. Now get off my nicely block structured lawn. |
|
Big Brother says 2 + 2 = 5.
|
Re: Authenticate or Math
2012-04-04 11:25
•
by
np
(unregistered)
|
I had looked through briefly but missed your comment. Serves me right for making coffee instead of reading TDWTF. Glad someone else had a similar thought. |
|
#ifdef REQUIRES_LOGIN
#define 4 5 #endif |
Re: Authenticate or Math
2012-04-04 11:37
•
by
Abso
(unregistered)
|
" || debug_mode" would be even easier to search for. |
Re: Authenticate or Math
2012-04-04 11:41
•
by
jumentum
(unregistered)
|
+ only morons commit debug code |
not to mention pre compiler directives can make this a non issue. define it as true for debug builds, but false for production builds. |
Re: Authenticate or Math
2012-04-04 11:49
•
by
Anon
(unregistered)
|
proughreaders, surely |
Re: Authenticate or Math
2012-04-04 11:50
•
by
fishdude
(unregistered)
|
Since you are dynamically building an SQL statement, I'll assume you are using PHP. Put all your WHERE clauses into an array, then use `implode()` to join the arrays into a string. $where[] = "param1 = 'fish'"; $where[] = "param2 = 'slap'"; $sql = "SELECT * FROM table WHERE " . implode(" AND ", $where); |
more likely a throw_up(); |
Re: Authenticate or Math
2012-04-04 11:52
•
by
LD
(unregistered)
|
Not only that, but there are quite a few compilers out there that won't allow you to write conditions that simply evaluates to either true or false, i.e. if(false) { ... }, because that produces unreachable branches. That includes things like if(expression || true) or if(expression && false) and things like that. The work around? ifdef (if there is a preprocessor); comment out the block; use conditionals (1==1, 2+2==4). By the way, there is no real reason you can't search for "|| true" because the only time you should have boolean literals is when you initialize a variable. "true" or "false" should never appear within a test. Just my $.02 |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |