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
Carbon dioxide
Oct 9, 2012

Real life horror: http://www.theregister.co.uk/2016/07/03/mri_software_bugs_could_upend_years_of_research/?mt=1467666616578

We're gonna run out of helium to cool the MRIs before this shitstorm is fixed.

Adbot
ADBOT LOVES YOU

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Carbon dioxide posted:

We're gonna run out of helium to cool the MRIs before this shitstorm is fixed.

Good news!

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I'm sure pumping the world's supply of helium out into space in the form of party novelties will never come back to bite us.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

quote:

The researchers used published fMRI results, and along the way they swipe the fMRI community for their “lamentable archiving and data-sharing practices” that prevent most of the discipline's body of work being re-analysed.

Isn't that a description of every research discipline ever?

Pollyanna
Mar 5, 2005

Milk's on them.


Not even 10AM and I've already encountered controller-level view rendering and magic number case clauses in loving Ruby. :bang:

It's going to be a long day.

Space Kablooey
May 6, 2009


Look on the bright side: You can start drinking at 10AM. :v:

Coffee Mugshot
Jun 26, 2010

by Lowtax

Pollyanna posted:

Not even 10AM and I've already encountered controller-level view rendering and magic number case clauses in loving Ruby. :bang:

It's going to be a long day.

Meh, that's basic hacking.

xzzy
Mar 5, 2009

Something that amused me on reddit:

https://www.reddit.com/r/wow/comments/4rhrxu/some_weird_crazy_stuff_going_on_with_a_scam_that/

Someone spots a scammer trying to get people to run commands in their WoW client, later starts seeing friends send private messages containing the same commands. People dig into what's going on and it turns out to be an exploit that overwrites a function that gets called every time a chat message is received, allowing the attacker to run their own code instead. It's then used to silently and remotely take over the victim's client.

The basic mantra of "don't run poo poo random people tell you to run" still applies here but it amuses me that this has existed in the game since day one.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

Pollyanna posted:

Not even 10AM and I've already encountered controller-level view rendering and magic number case clauses in loving Ruby. :bang:

It's going to be a long day.
It's probably best to stop assuming that all code you encounter is completely perfect and refactored to perfection :)

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Sagacity posted:

It's probably best to stop assuming that all code you encounter is completely perfect and refactored to perfection :)

It would be nice to see the occasional example of basic competence, though.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
It's likely not possible to snippet the code, but our front-end datagrid now has click event bindings on all 5k+ *rows* rather than the main grid viewport.

I didn't want that JS performance anyway.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

Cuntpunch posted:

It's likely not possible to snippet the code, but our front-end datagrid now has click event bindings on all 5k+ *rows* rather than the main grid viewport.

I didn't want that JS performance anyway.

We're doing this where I work, too. We have jQuery DataGrids that can be very large, and they all have at least one "click to expand" event. Some pages have more. I found and fixed a wonderful bug that I cannot believe went unnoticed as long as it did. We had an event function that was binding itself to the event. Every time you performed the action that triggered the function, it would fire x times, and each of those would bind another copy of the function to the event. The first time a page loaded, it fired once, and all was well, except that it rebound itself to the event that triggered it. The second time, it fired twice, and also bound itself twice more. Then four, then eight, then sixteen. After a few clicks, the system would be ground to a halt. It probably doesn't say anything good that none of the users thought this was unusual enough to be worth mentioning. "Oh. Another page that is unusably slow. How quaint."

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

Centripetal Horse posted:

We're doing this where I work, too. We have jQuery DataGrids that can be very large, and they all have at least one "click to expand" event. Some pages have more. I found and fixed a wonderful bug that I cannot believe went unnoticed as long as it did. We had an event function that was binding itself to the event. Every time you performed the action that triggered the function, it would fire x times, and each of those would bind another copy of the function to the event. The first time a page loaded, it fired once, and all was well, except that it rebound itself to the event that triggered it. The second time, it fired twice, and also bound itself twice more. Then four, then eight, then sixteen. After a few clicks, the system would be ground to a halt. It probably doesn't say anything good that none of the users thought this was unusual enough to be worth mentioning. "Oh. Another page that is unusably slow. How quaint."

See I could at least understand it if it was something like expandable rows. But the use case itself(capture when the user has clicked on the visible area of the grid) just doesn't demand that sort of supposed solution. Most of the devs I work with use shotgun solutions like this. The amount of * selectors in our styles is...concerning to me.

Spatial
Nov 15, 2007

"Hi Spatial, you've really excelled here with the CoolProduct 2000 and we'd like you to work on our next big project. It's a life critical application so we have to follow the strictest standards..."

I open the project. What do I see? Buffer overflow vulnerabilities built into every function in the core API for absolutely no reason. Parameters passed to functions via void* and cast to the right type at the point of use. Duplicate types and enums with different values in different files. C files with header guards in them. A fundamentally single threaded design in a multi-core embedded system becase "we can move code to the other core later".

Bonus prize: unlike the previous project, the full source code will be visible to the customer.

Pollyanna
Mar 5, 2005

Milk's on them.


What it seems like they posted:

"Hi Spatial, you've really excelled here with the CoolProduct 2000 and we'd like you to work on our next big project. It's a life critical application so we have to follow the strictest standards..."

What they really posted:

"Hi Spatial, we're hosed hard and need your help to make this not lovely before our customer demo early next week. BTW you won't get compensated for this. Thanks!"

Ornedan
Nov 4, 2009


Cybernetic Crumb
Found a couple of fun things while trying to figure out why an image codec does not compile with Java 8. Turns out older compilers allowed access to an uninitialised final field if it's this-qualified.

Java code:
public class What
{
  final int n;
  int[] a = new int[this.n]; // Error in 8 only
//int[] b = new int[n];      // Error in 7 and 8

  final int x;

  public What(int n)
  {
    this.n = n;

    this.x = this.x;         // Error in 8 only
//  this.x = x;              // Error in 7 and 8
  }

  public static void main(String[] args)
  {
    What w = new What(1);

    System.out.printf("w.n: %d; w.a.length: %d\n",w.n,w.a.length);
    // w.n: 1; w.a.length: 0
  }
}

CPColin
Sep 9, 2003

Big ol' smile.
Java's class and instance initialization logic only extremely rarely affect anything, but, boy, when they do, it's amazing. :allears:

(In this case, I bet the old compilers were figuring the values had already been initialized because some implicit constructor had already run or something.)

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Some Java:

code:
SimpleDateFormat dateFormat = new SimpleDateFormat("MMddyy");
Date foo = dateFormat.parse("2016-7-11");
Month 20? Surely it should generate an error.

Nope! This actually parses into a date: "Sun Aug 16 00:00:00 CST 7" (This date is BC)

You can turn this rollover behavior off by doing dateFormat.setLenient(false), but the documentation for that is not very good, and nowhere does it mention the possibility of month/day rollover.

sarehu
Apr 20, 2007

(call/cc call/cc)
So wait, it turns -7 into 8 BC, then rolls that over into 7 BC? Awesome.

Contra Duck
Nov 4, 2004

#1 DAD
I used to be confused why a webservice was giving me dates like "09-07-10007" until I realised they were storing records with no end date as "99999999" and the webservice was just adding 99 months and 99 days to Jan 1 9999.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Contra Duck posted:

I used to be confused why a webservice was giving me dates like "09-07-10007" until I realised they were storing records with no end date as "99999999" and the webservice was just adding 99 months and 99 days to Jan 1 9999.

Was this epic? Cuz that sounds like something I could explain if it was :).

1337JiveTurkey
Feb 17, 2005

Same lenient formatting but they used 00000000 to indicate that they didn't have a date. Year 0 AD wraps around to 1 BC. Month 0 becomes month 12 of the previous year so December 2 BC, and then day 0 becomes the last day of the previous month resulting in November 30, 2 BC.

Contra Duck
Nov 4, 2004

#1 DAD

LeftistMuslimObama posted:

Was this epic? Cuz that sounds like something I could explain if it was :).

Nah on the other end was some monolithic banking mainframe where 'null' wasn't an option so they used a bunch of bizarre workarounds instead.

Spatial
Nov 15, 2007

Hey guys we need a consistent style for this new project.
C++ code:
HMMM_TYPE ok_how_AboutThisOne( YEAH_THAT_WILL_DO_t *const pYeahOkay )
{
    im_down_Here_Tho();
}
Unfortunately this sagely advice was interpreted as four styles per line.

Spatial
Nov 15, 2007

Digital hardware designers are the god kings of bad programming. Their unbeatable mastery of being terrible is beyond the ken of the mortal realm.

God help me, please.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Spatial posted:

Digital hardware designers are the god kings of bad programming. Their unbeatable mastery of being terrible is beyond the ken of the mortal realm.

God help me, please.

I feel like I've already mentioned the piece of code that had a huge empty loop, which I had first assumed had to do with timing for the hardware, until I found out that what was really creating the necessary delays was a judicious use of reads from the printer port.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Absurd Alhazred posted:

I feel like I've already mentioned the piece of code that had a huge empty loop, which I had first assumed had to do with timing for the hardware, until I found out that what was really creating the necessary delays was a judicious use of reads from the printer port.

yep, no way that could ever lead to a vulnerability, no sir.

Carbon dioxide
Oct 9, 2012

Kilson posted:

Some Java:

code:
SimpleDateFormat dateFormat = new SimpleDateFormat("MMddyy");
Date foo = dateFormat.parse("2016-7-11");
Month 20? Surely it should generate an error.

Nope! This actually parses into a date: "Sun Aug 16 00:00:00 CST 7" (This date is BC)

You can turn this rollover behavior off by doing dateFormat.setLenient(false), but the documentation for that is not very good, and nowhere does it mention the possibility of month/day rollover.

Oh god, that's an old java.util.Date isn't it? That's the old crappy implementation you never ever want to touch anymore. Use java.time.LocalDate (and the java.time.format.DateTimeFormatter for formatting Strings) if you can use Java 8. Otherwise, import and use the Joda Time library, which is the same thing, it just got internalized as java.time in Java 8.

Absurd Alhazred
Mar 27, 2010

by Athanatos

LeftistMuslimObama posted:

yep, no way that could ever lead to a vulnerability, no sir.

If someone had hardware access to that machine during initialization then using that somehow would be the least of their worries. Anyway, it doesn't do anything with the data from that read.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Absurd Alhazred posted:

If someone had hardware access to that machine during initialization then using that somehow would be the least of their worries. Anyway, it doesn't do anything with the data from that read.

This statement assumes there are no other defects in the code that would enable the attacker to use this to get data into memory and use other vulnerabilities to do stuff with it. Not saying it's super likely, but why feel safe behind a locked door when you left the window open, ya know?

Absurd Alhazred
Mar 27, 2010

by Athanatos

LeftistMuslimObama posted:

This statement assumes there are no other defects in the code that would enable the attacker to use this to get data into memory and use other vulnerabilities to do stuff with it. Not saying it's super likely, but why feel safe behind a locked door when you left the window open, ya know?

If you even got to a point where you were running this program, you had the type of access where you wouldn't need to use any buffer overflow vulnerabilities I probably left there to inject code that would then somehow read additional data from the port (and even then, why do that when you could just do it inside the buffer overflow anyway?). It would be more like locking an internal window, not an outside-facing one.

The more I think about the architecture I built there, the more I'm glad that I didn't work there very long, because this would have come back to bite me.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Absurd Alhazred posted:

The more I think about the architecture I built there, the more I'm glad that I didn't work there very long, because this would have come back to bite me.

Everyone has at least one job like this.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
code:
//Do not change to match database, in dev and test environments this is correct
//I tried adding 2 hours and it worked locally but then is 2 hours too high on server

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Carbon dioxide posted:

Oh god, that's an old java.util.Date isn't it? That's the old crappy implementation you never ever want to touch anymore. Use java.time.LocalDate (and the java.time.format.DateTimeFormatter for formatting Strings) if you can use Java 8. Otherwise, import and use the Joda Time library, which is the same thing, it just got internalized as java.time in Java 8.

Oh, definitely. Some of that handling code was written several years ago before Java8, and apparently nobody knew about Joda.

Actually, 90% of our time/date handling just uses java.util.Date though. :(

Volmarias
Dec 31, 2002

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

Spatial posted:

Digital hardware designers are the god kings of bad programming. Their unbeatable mastery of being terrible is beyond the ken of the mortal realm.

God help me, please.

Dehumanize yourself and face towards embedded.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
php:
<?
function is_equal($val1, $val2) {
    if ($val1 == $val2) {
        return true;
    } else {
        return false;
    }
}
?>
e: it gets better...

php:
<?
(is_equal($selected, $selected) ? "selected" : "")
?>

bobthecheese fucked around with this message at 02:59 on Jul 15, 2016

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I think I see the problem: you're using PHP.

Contra Duck
Nov 4, 2004

#1 DAD

bobthecheese posted:

php:
<?
function is_equal($val1, $val2) {
    if ($val1 == $val2) {
        return true;
    } else {
        return false;
    }
}
?>

After reading this thread for a years, I can't tell if this is bad because it's just dumb code or if it's actually needed because php equality testing is that broken :(

Xarn
Jun 26, 2015

Contra Duck posted:

After reading this thread for a years, I can't tell if this is bad because it's just dumb code or if it's actually needed because php equality testing is that broken :(

Its dumb code. If it used "===" it might've been excusable, but not with "==".

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill
I mostly use ====, or ===== when I need to be absolutely sure things are identical

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