String Cleanup Results On OpenBSD 53
Dan writes "OpenBSD's Theo De Raadt provides an update on his team's efforts to remove potential buffer overflows within OpenBSD code by always calculating what the bounds of an operation are. They have been going through the source tree cleaning out all calls to sprintf(), strcpy(), and strcat(). Theo says that they have removed (replaced) approximately 2000 occurences of these functions." (The same buffer overrun-squashing effort was mentioned earlier this month.)
BSD Coding Standard. (Score:3, Insightful)
If most developers are still using these "trivial" funcs, I'm scared what other funcs are just as buggy!
Funny how one can forget all about these "harmless" bad practises. Time to add it to the internal coding standard.
Re:BSD Coding Standard. (Score:5, Informative)
Re:BSD Coding Standard. (Score:2)
If most developers are still using these "trivial" funcs, I'm scared what other funcs are just as buggy!
Funny how one can forget all about these "harmless" bad practises. Time to add it to the internal coding standard. :)
eliciting parent's informative reference on proper coding practices.
I wish it were that simple. Recently starting at a new position, I was horified at the number of strcpy()s, strcat()s, and sprintf()s peppered throughout code -- mostly building up a string to be
Re:BSD Coding Standard. (Score:2)
o perhaps it's better to use a language where the default easy thing to do is to use the checked version (say, Java)?
In some instances, yes.
However, in some instances, those checks can be unnecessary time killers, when you are trying to squeeze the last bit of performance from a program, and have done careful static analysis to ensure they don't happen, you don't need to check at run-time.
IOW, you need to be able to chose between the "luxery car" with the "smooth ride", and the Formula-1 racer.
The t
Re:BSD Coding Standard. (Score:1)
Also, I don't think that C really gets you closer to the "bare metal," unless you're thinking about 20 or 30 year old computers. Computers these days really don't fit the model that C purports: they are parallel, out of order, with a significant memory performance hierarchy. It's a real shame the kinds of games we play with our compilers as a res
Re:BSD Coding Standard. (Score:2)
Point noted, but I meant "... when compared to Java". C still has a lot of horsepower on uniprocessors, without esoteric memory and interconnect performance hierarchies. It isn't popular without good reason, those those reasons, as you note, are starting to get dated. Though, it is probably
Re:BSD Coding Standard. (Score:1)
char buf[20];
GetUserInput("Input the number of seconds since you last ate something", buf);
when the only person who has access to that vulnerability is the user himself? I bet 95% of all the useful programs out there fall into this category. It's a waste of time to put an ultra-secure lock on the do
Re:BSD Coding Standard. (Score:2)
Re:BSD Coding Standard. (Score:1)
Re:BSD Coding Standard. (Score:2)
There are two different ways of dealing with this -- either auditing your entire system for exploits assuming that any piece of code may be running with elevated privs a
Re:BSD Coding Standard. (Score:2)
You're thinking of OpenBSD.
Re:BSD Coding Standard. (Score:1)
Yeah, since the article was about Open, I didn't think I had to specify it.
OpenBSD (Score:1, Troll)
Yet they've launched a major effort to cleanup 2,000 unsafe string functions in the last two months...
What has Theo been doing all this time other than being an obnoxious prima donna and re-writing packet filters because of some minor squabble?
Re:OpenBSD (Score:2)
Security is a constantly moving target (Format string vulnerabilities are very new on the scene for example). The string functions that were replaced did not have holes, they were replaced because they wanted to avoid even the possibility of a vulnerability and because they wanted to clear all standard string operations out to make searching for possible future vulnerabilities easier
Re:OpenBSD (Score:2, Flamebait)
Unchecked string problems have been known since the standard C libraries came out. I first heard about them around 1995.
All I'm trying to say is that OpenBSD would be a much more secure system if Theo spent more time working on it rather than grandstanding.
Re:OpenBSD (Score:2)
Re:OpenBSD (Score:1)
Re:OpenBSD (Score:2)
I'm sure use of unbounded string functions were looked over and checked for possible bugs. This just makes it harder for another kernel bug to cascade into a kernel compromise.
Believe me, this is way, way more than our friends in Redmond have been doing.
Re:OpenBSD (Score:2)
Jeremy
Re:OpenBSD (Score:2)
Re:OpenBSD (Score:3, Interesting)
Re:OpenBSD (Score:2)
For someone like me who doesn't really use BSD and sees everything going on with it as a spectator, sometimes the political and other issues surrounding it obfuscate the technical detail.
Re:shame on you slashdot editors (Score:1)
You obviously do not understand how
Also, by removing down-moderating this post, you are proving my point that you censor what isn't convenient or fits your own purposes.
Once again, read the FAQ. Nothing is censored. Set your threshold to -1 and you can read all the trolls, like this one.
You are clueless.
Shifting so much (Score:3, Interesting)
But more importantly, why wasnt it possible to replace the functions in the library with something (if a bit slower) robust?
Are we witnessing the evolution of the New Libc(tm) ?? Can I patent it?
Because the functions don't spec. a buffer length (Score:3, Informative)
To answer your question, it's not possible to replace the original functions in libc because there's no maximum length param in those functions (unlike the safer "n" equivalents like snprintf()).
Re:Because the functions don't spec. a buffer leng (Score:2)
Exactly, the bugs are in libc, not the calling programs. OpenBSD should remove all dangerous libc functions, like sprintf() and strcpy(). Then unsafe user programs will not even compile. If OpenBSD is really, really serious about security, they could then disallow these unsafe programming practices. Source code ported to the new restrictive OpenBSD libc would benefit on other platforms, too.
If forever removing strcpy() and friends is just too radical, OpenBSD could use a transitional approach by moving the
Re:Because the functions don't spec. a buffer leng (Score:2)
Would be pretty neat.
Re:Because the functions don't spec. a buffer leng (Score:1)
Also, the OpenBSD team isn't going to touch most of the third party code in the tree: "We are obviously not doing this to some parts of the tree which we borrow from other projects. In particular, the gn
I think Theo misunderstood... (Score:2, Funny)
snprintf() on Win32 with MSVC6 (Score:1)
#include
void main(void){
char buff[1024];
snprintf(buff, 1024, "Test");
_snprintf(buff, 1024, "Test");
return;
}
GRR!! Very annoying when trying to write code for both win32 and *nix.
Re:snprintf() on Win32 with MSVC6 (Score:2)
Re:snprintf() on Win32 with MSVC6 (Score:2)
Re:snprintf() on Win32 with MSVC6 (Score:2)
So fix it...
#ifdef WIN32
#define snprintf _snprintf
#endif
Or get the free Borland compiler.
Re:snprintf() on Win32 with MSVC6 (Score:1)
Also, this seems to be the reasoning for the odd va_arg macros and these functions defined in stdio.h
Purpose:
* This file defines the structures, values, macros, and functions
* used by the level 2 I/O ("standard I/O") routines.
* [ANSI/System V]
Re:snprintf() on Win32 with MSVC6 (Score:1)
Re:snprintf() on Win32 with MSVC6 (Score:1)
#define BUFSIZE 1024
main()
{
char buf[BUFSIZE];
snprintf(buf, BUFSIZE-1, "foo");
}
Spring Cleaning (Score:1)
Groan. Umm, we do spring cleaning in the southern hemisphere too ya know! Our spring follows winter (the cold one) and preceeds summer (the hot one) as well!! The only difference is the time of year.
This doesn't mean much... (Score:1)