impressivewebs / HTML9-Responsive-Boilerstrap-js

HTML9 Responsive Boilerstrap JS
https://html9responsiveboilerstrapjs.com/
1.41k stars 228 forks source link

Improper Subtraction Conventions #55

Closed CalMlynarczyk closed 9 years ago

CalMlynarczyk commented 12 years ago

Using the minus (-) operator is a poor coding convention. It can lead to buffer overflows and there is a known security exploit where the client can subtract a value from itself and get zero. The proper way to handle subtraction in JavaScript is to flip the sign bit of the integer so that the value is negative and then instead use the addition (+) operator.

The JS parser in Firefox 18 (Release Date: June 20, 2012) is much improved to better support standards, and no longer handles subtracting positive numbers without throwing an exception.

IE 5 also has the same issue, but instead seg faults. I discovered a hack to fix this if you wish to continue using the minus (-) operator:

var a = 5;
var b = 6;
"";
"";
"";
1++;
a = a - b;
// Make sure to use exactly three lines of empty quotations
// EDIT: DO NOT INCLUDE ABOVE COMMENT! BREAKS IE 7 COMPATIBILITY!
tianshuo commented 12 years ago

How do you know if the CPU is big-endian, little-endian, medium-endian, or deluxe-endian with double-cheese toppings?

mgorman commented 12 years ago

let's not discriminate, here... it could also be american-endian...

CalMlynarczyk commented 12 years ago

I think we need to investigate further. I'll create a GUI interface using Visual Basic and see what I can find out.