Some Linux kernel security vulnerabilities
Posted Nov 10, 2004 23:57 UTC (Wed) by
jwb (guest, #15467)
In reply to:
Some Linux kernel security vulnerabilities by NAR
Parent article:
Some Linux kernel security vulnerabilities
I agree that this is a common trap in C programming. Instead of:
return_value_or_status = function(args);
I prefer to see:
status = function(&return_value, args);
Which also has the advantage that more than one value can be returned. read(2), in particular, is almost impossible to use, and this goes for all Unix across all time, not just for Linux. The conflation of the file position and the status of the result is very confusing. And, if read returns -1, there's absolutely nothing you can do about it without closing the fd and starting from scratch (because the file position becomes undefined).
Okay, the whole Unix API is hard to use, and so is C ;)
(
Log in to post comments)