- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
That's a goat, it's cloven footed. Asses are equids, and have only one hoof per leg.
Admin
Admin
The same applies to most of the code SODs posted !
Admin
VeryHidden is used very less
Admin
Admin
Yes, I'm aware that the hypothetical exchange above resulting in the WTF code snippet is two individuals who have heard some buzzwords but don't actually understand what they're doing, managing to create something even more dysfunctional than what either of them would have created separately. To me, the amusing bit is that either would have created something that might have worked in the normal case, but failed when confronted with a malicious user. But by working together, they managed to create something that fails in cases of both malicious and normal users.
We don't see the code for the stored procedure, but I'll bet dollars to donuts that if it does something like a last name search, it will fail when the user enters O'Connell, once the EXEC command has been ruthlessly mangled by this abysmal front-end coding. Whether it's still vulnerable to injection attacks depends a lot on how competent the person who coded the stored proc was; hopefully this person was in no way related to the front-end coders.
The really sad part is how easy it is to code this correctly ...
Admin
You forgot the most obvious one, FileNotFound.
Admin
No . a dir will be created unless both dir and file exist w/ the name. and there will be an error
Admin
Oh and by the way, anyone want to see my private carrot ?
Admin
So...you're saying that some of the code included as part of a Daily WTF post isn't actually very good code?
Have the site owners been informed?
Admin
lol omigosh frist!!11!!
Admin
You've missed the ultimate form of invisibility for a document - SavedToSharepoint
Admin
s.ToString() is surely redundant, might also be a remnant of some refactoring or copy/paste, but is still very minor, not a WTF for sure unless that specific developer wrote that all the time.
I'm against compacting that into one line, which gains nothing and complicates debugging. We can debate that, of course, but I wouldn't call WTF on that code at all.
I also imply that EvalToString does some kind of "EVALUATION" of the statement argument. Like you can pass, say "=A1+B2" or "=$sdjfhskdfh" or whatever valid expression in whatever sublanguage it is, and it returns a value of some kind, otherwise it would be named "ConvertToString" probably.
Admin
Assuming this is php, file_exists will return true if either a file or directory exists; thus is_dir() == true implies file_exists() == true.
Admin
In 1986, India was being given 7 Polaroid camera from British govrenment. Most of the fotos are being lost. :(
Admin
Thank you.
Admin
Geoffrey, you used the wrong log-in today.
Admin
While you're all stumbling over yourselves to argue that evaltostring may or may not be a WTF, everyone seems content that there's an entire subroutine which is nothing more than a wrapper for int.parse and doesn't even handle exceptions. int.tryparse, anyone?
Admin
Combined with your last post, I'm beginning to think that it is you who is Geoffrey.
evalToString almost certainly evaluates its argument, and returns the result of that evaluation, not the original string
evalToInteger isn't just a wrapper for int.parse, since it also performs the aforementioned evaluation
Not everyone wants to handle exceptions immediately. Especially in a case like this where the appropriate response is probably to just let the FormatException bubble up to the caller.
Admin
Admin
Given the variable name of "statement" I'm thinking that the original might contain some sort of markup rather than the final data. Say "Dear @Salutation @Firstname @Lastname".
Admin
Why not replace with a blank string?
replace('/', '')
Admin
Admin
Admin
FTFY
Admin
Admin
The problem is that the "||" should be "&&". The way it is now, it's a little like saying:
At first glance, you'd think this code would print an error message whenever it got an unexpected input, like "12" or something like that. But in actuality, every input is either not equal to "male" or not equal to "female" (or both), making the condition equivalent to "if (true)", making users wonder why "male" and "female" are such esoteric genders.
So in the original code, the exec() command will get run no matter what, which is probably not what the programmer intended.
Admin
Well there is is_file() that returns true if the file exist and it's a regular file and is_link() that does the same for symbolic links.
The file file_exists() is returns true if there is anything (file, dir or link) with the supplied name in the directory, probably named as such because in Unix/Linux "everything is a file"...
Fixing this code (assuming there may be a file or link called "test") is not as easy, if the rest of the code assumes the a directory named "test" is created after this code is run... (But in practice; the directory will probably be controlled by this application anyway, so the assumption that no regular file or link with this name is present is probably safe)
Admin
I keep hearing about this Sharepoint, and even got asked to "set it up" once... I even installed it. But I still can't figure out WTF it's meant to be. I guess that makes it perfect Enterprise software?
Admin
That's not an ass.
Also, I think your complimentary internet stalker is morphing into Molesworth.
Admin
Admin
Are you saying that "exec spRequestInitechData 'O'Connel" Would be in any way better? Admittedly, the code crashing might be a relief for all involved. Also, the inside of the SP doesn't have to be involved in an injection attack in this case.
I guess something involving prepared statements that is two or three times as long?Admin
Admin
No, you can't. Both parameters of String.replace() are characters, not strings.
If you meant String.replaceAll(), then yes. But this was added to Java in 1.4, so it may or may not have been available when the code was first written. (And I know of a few servers that haven't still been upgraded from 1.3, so the code does not even have to be ancient for that to be true.)
Admin
That statement is building a string to be sent to the DB engine for parsing.
Exec spInitechData('O'Bryan');
See a problem with that statement?
Man, the quality of the reviewers on this site has really slipped lately. Y'all youngsters need to put on your thinking caps and think things through, and not be so quick to slam code that doesn't "make sense" to you.
Admin
You didn't miss anything. He's an idiot. The real WTF anymore on this site is the remarkable lack of comprehension, coupled with a true sense of arrogance.