News for hackers. Stuff that matters.
Re:Critical PRNG Bug in NetBSD Kernel by xkcdfanboy on Friday March 22, 2013 @01:14AM (#5421487)
Just in case anyone is curious, the error was having `sizeof(key - r)` instead of `sizeof(key) - r`

Rookie mistake!

Re:Critical PRNG Bug in NetBSD Kernel by riffraff on Friday March 22, 2013 @02:27AM (#5421651)
I wonder, what sort of technology would have avoided this? The "key -r" bit seems a bit suspicious type wise
Re:Critical PRNG Bug in NetBSD Kernel by Tobu on Friday March 22, 2013 @07:26AM (#5422304)
-Wsizeof-pointer-memaccess (Clang and GCC 4.8) is the only sizeof-related warning I know of, which warns about some cases where both pointer and size are immediately passed to a handful of builtin functions (in GCC, some among mem…, str…, s…printf). C's typing is much too weak for -Wsizeof-pointer-memaccess to be generally useful.

Without getting into typing, a simple

  warning: arithmetic inside sizeof
would catch this. I don't think it would catch much noise, I don't see any useful uses of pointer arithmetic immediately inside a sizeof. It's a bit specific though, are there more functions that would benefit as well?
Re:Critical PRNG Bug in NetBSD Kernel by marshray on Friday March 22, 2013 @02:33AM (#5421661)
Yeah, why would you care about the size of a temporary arithmetic expression?
Re:Critical PRNG Bug in NetBSD Kernel by ElectroPrime on Friday March 22, 2013 @02:41AM (#5421686)
Well... sizeof of an expression is mostly useful for not repeating yourself in cases when you need the size of a type you already have some way of referencing, as in

  a = malloc(sizeof(*a));
It's also useful for various hacks (stuff like compile-time assert macros), since it doesn't evaluate the expression, only its type.
Re:Critical PRNG Bug in NetBSD Kernel by marshray on Friday March 22, 2013 @02:53AM (#5421712)
Sure, I can think of plenty of ways it could arise via metaprogramming. I don't know if I would want such a warning enabled in my own template-heavy C++ code.

But it perhaps it could be useful for those following the NetBSD style. :-)