Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
substitute
Aug 30, 2003

you for my mum
The exciting follow-up to "I hate graphic designers."

main nav example:

code:
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<META NAME="viewport" CONTENT="WIDTH=DEVICE-WIDTH, INITIAL-SCALE=1, MINIMUM-SCALE=1, MAXIMUM-SCALE=1" />
	<link rel="stylesheet" href="/css/styles.css">
</head>
<body>

<div id="nav-container">
    <div id="site-nav" class="content-group">
        <a href="index.php">
            <div class="content-group-item header">
                <div class="content-group-wrapper">
                    <div class="content-group-data logo">
                        <span class="content-group-label"><h1>BLAH</h1></span>
                        <span class="content-group-icon"><img class="nav-logo" src="/img/global/blah-logo.jpg"/></span>
                    </div>
                </div>
            </div>
        </a>
       
        <a href="index.php">
            <div class="content-group-item feature">                 
                <div class="content-group-wrapper">
                    <div class="content-group-data blah2-bg">
                        <span class="content-group-label"><h1>BLAH 2</h1></span>
                    </div>
                </div>
            </div>
        </a>
        
        <a href="index.php">
            <div class="content-group-item feature">
                <div class="content-group-wrapper">
                    <div class="content-group-data blah3-bg">
                        <span class="content-group-label"><h1>BLAH 3</h1></span>
                    </div>
                </div>
            </div>
        </a>
        
        <a href="index.php">
            <div class="content-group-item">
                <div class="content-group-wrapper">
                    <div class="content-group-data">
                        <span class="content-group-label"><h1>BLAH 4</h1></span>
                    </div>
                </div>
            </div>
        </a>
        
        <a href="index.php">
            <div class="content-group-item">
                <div class="content-group-wrapper">
                    <div class="content-group-data">
                        <span class="content-group-label"><h1>BLAH 5</h1></span>
                    </div>
                </div>
            </div>
        </a>
    </div>
</div>
    
<div id="content-container">
        <div class="section">
    <div id="homepage-hero" class="content-group">
       
        <a href="index.php">
            <div class="content-group-item">
                <div class="content-group-wrapper">
                    <div class="content-group-data">
                        <span class="hero-container someproduct-bg"> 
                            <span class="hero-cta-container">
                                <span class="hero-cta-inner-container">Call to action</span>
                            </span>
                        </span>
                    </div>
                </div>
            </div>
        </a>
        
        <a href="index.php">
            <div class="content-group-item">
                <div class="content-group-wrapper">
                    <div class="content-group-data">
                        <span class="hero-container another-product"> 
                            <span class="hero-cta-container">
                                <span class="hero-cta-inner-container">Call to action</span>
                            </span>
                        </span>
                    </div>
                </div>
            </div>
        </a>
        
    
    </div>
    </div>
</div>
<div id="footer-container">
    <span class="upper"><h1>Contact Us</h1></span>
    <span class="lower"><p>BLAH BLAH is a registered trademark of BLAH BLAH.</p></span>
</div>
    
</body>
</html>
How could someone type this out and not stop to think, "There has to be a better way." (??)

substitute fucked around with this message at 16:35 on Feb 21, 2014

Adbot
ADBOT LOVES YOU

EntranceJew
Nov 5, 2009

I sincerely hope that's generated code. Code generated by a tool produced in 2004.

substitute
Aug 30, 2003

you for my mum

EntranceJew posted:

I sincerely hope that's generated code. Code generated by a tool produced in 2004.

Well, no. The "senior" graphic designer, in 2014, typed/copy-pasted that out to get started on a new project that is, supposedly, due in a week (because of a publication / product ad).

I am not kidding.

That Turkey Story
Mar 30, 2003

Jewel posted:

I forgot we talked about this DON'T START ANYTHING we've done it before see this post if you want to see the discussion on it. Move along :allears:

I was just about to link that.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING

substitute posted:

The exciting follow-up to "I hate graphic designers."

How could someone type this out and not stop to think, "There has to be a better way." (??)

Maybe he was just trying to have his very own spaceship battle?

code:
.spaceshipbattle#battlewithspaceships_id1 {

display: spaceships !important;

}
I hear your pain, though. Five minutes ago a co-worker asked me if this syntax was correct:

code:
SELECT id FROM table WHERE (userid=234 AND assignment IN(31,32,34,37)AND (userid=432 AND assignment IN(67,1,9,31,677)AND (userid=654 AND assignment IN(99,999))
Me: "You can't use AND that way - userid can't be both 234, and 432, and 654 all in the same row. You want to use 'OR'."
Him: "No, AND. It's in (). Do I need to do it in multiple SELECTs?"

I want to cry.

Sulla Faex fucked around with this message at 12:46 on Feb 21, 2014

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
I wrote him the correct query, or at least syntactically-correct query (who knows what the gently caress he needs it to do), and ten minutes later he asks me if this next query is correct:

code:
UPDATE table SET status=50 WHERE ( (SELECT id WHERE userid=3 AND assignment IN(7,1246,1207)) AND (SELECT id WHERE userid=4 AND assignment IN(7,1262)) AND (SELECT id WHERE userid=6 AND assignment IN(14,37,258,414)) )
He has got to be trolling me.. there's no way...

KaneTW
Dec 2, 2011

Why are you still working with him? It's obvious he doesn't understand basic logic.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
The project is almost over, it's a tiny company, and I'm not responsible for hiring/firing.

Well, I say the project is almost over, but it could go on for months and months more..

The only way to survive is to shrug, pretend you didn't see all the poo poo you just saw, and collect your paycheque. I can't do anything to fix the situation and I've been sick for at least 6 weeks straight now, with maybe 2-3 periods of 3 days "recovery" between each bout, so I'm not signing up to get involved in this stuff. I make sure my work is done, I help them when they ask, and that's the extent of it. They're paid the exact same as me, for reference, so I'm not going to go out of my way to nanny them, teach them common sense, or cover for them.

I just need to vent sometimes :x

Nf3
Oct 9, 2012

Suspicious Dish posted:

Booked a flight on JetBlue instead.

Did you really need to include the '.', though?

quiggy
Aug 7, 2010

[in Russian] Oof.


Nf3 posted:

Did you really need to include the '.', though?

Both TSA agents and airline personnel can be incredibly anal about any minuscule discrepancies between what a ticket says and what someone's ID says. I don't blame him at all for deciding to play it safe.

zeekner
Jul 14, 2007

Found this gem in the documentation for Android's WebView:



I have no idea why this is exposed in the webkit api.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Uncomfortable Gaze posted:

Found this gem in the documentation for Android's WebView:



I have no idea why this is exposed in the webkit api.

quote:

Added in API level 1

:ms:

Lots of dumb/optimistic stuff was done when android first launched. Not all of it was a great idea.

apseudonym
Feb 25, 2011

code:

    if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
        goto fail;
        goto fail;
    if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
        goto fail;

	err = sslRawVerify(ctx,
                       ctx->peerPubKey,
                       dataToSign,				/* plaintext */
                       dataToSignLen,			/* plaintext length */
                       signature,
                       signatureLen);
	if(err) {
		sslErrorLog("SSLDecodeSignedServerKeyExchange: sslRawVerify "
                    "returned %d\n", (int)err);
		goto fail;
	}

fail:
    SSLFreeBuffer(&signedHashes);
    SSLFreeBuffer(&hashCtx);
    return err;

Good job Apple, SSL bug of the year.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Where did you find that? It's not in any publicly released version of libsecurity_ssl I could find, like this one:

http://opensource.apple.com/source/libsecurity_ssl/libsecurity_ssl-55003/lib/sslKeyExchange.c?txt

vOv
Feb 8, 2014

Wait, wouldn't that just cause the validation to always fail, not always succeed?

apseudonym
Feb 25, 2011

Suspicious Dish posted:

Where did you find that? It's not in any publicly released version of libsecurity_ssl I could find, like this one:

http://opensource.apple.com/source/libsecurity_ssl/libsecurity_ssl-55003/lib/sslKeyExchange.c?txt

http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c?txt

vOv posted:

Wait, wouldn't that just cause the validation to always fail, not always succeed?

If the second goto is hit what is the value of err?

vOv
Feb 8, 2014

apseudonym posted:

If the second goto is hit what is the value of err?

... oh, duh.

teamdest
Jul 1, 2007
Wow. Braces could have saved the day. That is perversely amusing to me.

For want of a brace, the kingdom was lost? I dunno. I swear I had something for this.

ctz
Feb 6, 2003

teamdest posted:

Wow. Braces could have saved the day. That is perversely amusing to me.

Any of:

  • braces,
  • consistent white space,
  • decent syntax highlighting,
  • static analysis,
  • code review,
  • testing,
  • consistent abstraction of the 'set err, goto fail' construction

Space Kablooey
May 6, 2009


apseudonym posted:

code:

    if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
        goto fail;
        goto fail;
    if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
        goto fail;

	err = sslRawVerify(ctx,
                       ctx->peerPubKey,
                       dataToSign,				/* plaintext */
                       dataToSignLen,			/* plaintext length */
                       signature,
                       signatureLen);
	if(err) {
		sslErrorLog("SSLDecodeSignedServerKeyExchange: sslRawVerify "
                    "returned %d\n", (int)err);
		goto fail;
	}

fail:
    SSLFreeBuffer(&signedHashes);
    SSLFreeBuffer(&hashCtx);
    return err;

Good job Apple, SSL bug of the year.

I'm really trying, but I can't understand what's the error.

apseudonym posted:

If the second goto is hit what is the value of err?

code:
err = SSLHashSHA1.update(&hashCtx, &clientRandom)
? :confused:

teamdest
Jul 1, 2007
there's two "goto fail" and no braces for the various "if" statements.

They wanted:

error_condition = <some combination of checks i don't care enough about SSL to investigate>. If those checks come to 0, we're okay, carry on. if those checks are >0, fail.

it does that, sets "err" to 0 appropriately. then it hits the second "goto fail" no matter what because it's not actually part of the if statement. because they didn't use braces. because someone wanted to "save" 6 characters of typing.

so the "err" is 0 but we fail anyway, and fail just puts us all the way at the end, past the actual SSL checking bullshit. This whole function goes "error was 0, everything's fuckin' good mate, carry the gently caress on we're safe as houses", but didn't do the ACTUAL IMPORTANT PARTS OF SSL BULLSHIT.

because "oh it's only a one-line check" or "it's cleaner and easier to read this way" or something equally stupid.


edit: this is the specific issue:

if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

HardDisk posted:

I'm really trying, but I can't understand what's the error.


code:
err = SSLHashSHA1.update(&hashCtx, &clientRandom)
? :confused:

code:
    
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
<---
goto fail;
At this point, err = 0, because the update method succeeded.

Now the verification method never gets called and the method that called this function thinks it succeeded because err = 0. So never actually verify the certificate, but report success.

Bruegels Fuckbooks fucked around with this message at 14:21 on Feb 22, 2014

Sir_Substance
Dec 13, 2013
To be honest, I'm taking this more as a lesson in why we don't use gotos then a lesson in correct bracket usage.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Sir_Substance posted:

To be honest, I'm taking this more as a lesson in why we don't use gotos then a lesson in correct bracket usage.

Two lines of "return err" at that position cause the same problem and don't use goto, so I think you're taking the wrong lesson.

Also isn't there a "code is trivially unreachable" compiler warning?

nielsm
Jun 1, 2009



pokeyman posted:

Also isn't there a "code is trivially unreachable" compiler warning?

What's the chance it's drowning in hundreds of other warnings?

teamdest
Jul 1, 2007
I get that this is a serious thing, especially in light of the NSA social engineering stuff going on, all that poo poo, but seriously:

1) It's really obviously one of those "Never ascribe to malice" situations.

2) It's also a blatant violation of at least 9 of the 4 rules of code safety.

The more I think about it, the stranger and funnier it gets. I hope this winds up as one of those "object lessons we joke about" for the next twenty years.

"Why is use of brackets important, kids?"
<Sigh> "Because nobody wants to be apple."

or as a Stop, Drop, Roll kind of ingrained lesson.

"What do you do when you get a compiler warning, kids?"

"Stop, Question Assumptions, Call your Code Buddy!"


It's like a beautiful flower of avoidable bad decisions and shortcuts.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

teamdest posted:

"Stop, Question Assumptions, Call your Code Buddy!"

I'm gonna start using this with my middle-schoolers.

Dren
Jan 5, 2001

Pillbug
I woke up to an IOS update because of an SSH issue. Little did I know I'd be reading about it an hour later in coding horrors thread.

Sidenote: the contract I work on explicitly forbids omitting the brackets. It's one of the only code style requirements, in fact it might be the only one.

I feel like it's sort of a silly requirement because as ctz mentioned, there are at least 6 other things you should be doing that would stop you from making this error. Then again, it can be a real problem.

evensevenone
May 12, 2001
Glass is a solid.

Sir_Substance posted:

To be honest, I'm taking this more as a lesson in why we don't use gotos then a lesson in correct bracket usage.

"if (error) goto fail" is an pretty common C construction when you aren't using exceptions, since otherwise you'd have to build the "failure" code path through conditionals the rest of the through the function, which would be way more error prone.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

evensevenone posted:

"if (error) goto fail" is an pretty common C construction when you aren't using exceptions, since otherwise you'd have to build the "failure" code path through conditionals the rest of the through the function, which would be way more error prone.

As opposed to C with exceptions?

Exceptions would be better than retvals if morons didn't sprinkle catch(...) {} all over codebases.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

nielsm posted:

What's the chance it's drowning in hundreds of other warnings?

Good point.

astr0man
Feb 21, 2007

hollyeo deuroga

Sir_Substance posted:

To be honest, I'm taking this more as a lesson in why we don't use gotos then a lesson in correct bracket usage.

Using gotos in cleanup code like this is fine and perfectly acceptable. It's also very common in kernel (de)initialization type stuff too.

biznatchio
Mar 31, 2001


Buglord

Bruegels Fuckbooks posted:

Exceptions would be better than retvals if morons didn't sprinkle catch(...) {} all over codebases.

On the other hand, you have morons using goto statements. Which is worse?

Steve French
Sep 8, 2003

Bruegels Fuckbooks posted:

As opposed to C with exceptions?

Exceptions would be better than retvals if morons didn't sprinkle catch(...) {} all over codebases.

There are C implementations of exceptions out there, it's just not provided by the language or standard library.

I know this because I had to use one for a while, and it was awful.

apseudonym
Feb 25, 2011

Sir_Substance posted:

To be honest, I'm taking this more as a lesson in why we don't use gotos then a lesson in correct bracket usage.

Sorry but gotos are very useful in c when you're doing lots of things that can fail and need to unwind and do cleanup in a sane way.

The take away should be where the gently caress was the review on that change? Someone made a dumb mistake and no one noticed.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Steve French posted:

There are C implementations of exceptions out there, it's just not provided by the language or standard library.

I know this because I had to use one for a while, and it was awful.

Yeah, I consider not having exceptions a feature, not a bug. I loving love integrating with libraries that throw exceptions in higher level languages, it's definitely my favorite part of writing glue code that makes poo poo talk to poo poo.

fritz
Jul 26, 2003

goto should no longer be considered harmful in 2014 when we have so many more control structures available to us now, such as "while".

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
goto fail; indeed

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance
Compiling C without -Wall -Werror or the moral equivalent is a horror.

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

HORATIO HORNBLOWER posted:

Compiling C without -Wall -Werror or the moral equivalent is a horror.

Worse is all the people complaining about "the nanny compiler".

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply