R
Richard Heathfield
Tor Rustad said:
Look up "if".
See? You do understand about "if".
Try it on this:
/* foo.h */
#ifndef H_FOO_H
#define H_FOO_H 1
void build_foo(char *foo, int bar, char *baz);
#endif
/* foo.c */
#include <string.h>
#include "foo.h"
void build_foo(char *foo, int bar, char *baz)
{
sprintf(foo, "<h%d>%s</h%d>", bar, baz);
}
What warnings do you get? Compilation need not be done all at one time.
Fine, so you agree that the best solution is to hire good people and make
sure they know what they're doing?
What do you mean by "clever"? Where I come from, it means "smart, bright,
intelligent" and is considered a compliment. If you mean someone who tries
to write difficult code to show off how well he can write difficult code
(instead of writing easy code that anyone could maintain), I wouldn't call
that "clever".
So, you wouldn't have replied then, given the same conditions.
if ( tor_eval(richard) == cluless )
goto no_reply;
This didn't make any sense, you did reply, didn't you?
Look up "if".
Either "I think /you/ are clueless" is *false*, or you are posting
nonsense. You cannot have it both ways:
if ( richard_eval(tor) == cluless )
goto post_reply;
See? You do understand about "if".
For an introduction to basic security principles, see e.g. [1]:
"Principle 32. Identify and prevent common errors and vulnerabilities
Discussion: Many errors reoccur with disturbing regularity - errors
such as buffer overflows, race conditions, format string errors,
failing to check input for validity, and programs being given excessive
privileges. Learning from the past will improve future results."
In my experience, the following bug is far more common than strncpy:
char *t;
strcpy(t, s);
The bug here is in failing to allocate *any storage at all* for t.
Such an error, is detectable by statically checking tools, if compiler
doesn't catch it, lint tools like e.g. splint does.
Try it on this:
/* foo.h */
#ifndef H_FOO_H
#define H_FOO_H 1
void build_foo(char *foo, int bar, char *baz);
#endif
/* foo.c */
#include <string.h>
#include "foo.h"
void build_foo(char *foo, int bar, char *baz)
{
sprintf(foo, "<h%d>%s</h%d>", bar, baz);
}
What warnings do you get? Compilation need not be done all at one time.
To be honest, in safety-critical or security-critical software, I can't
ever remember being hit by buffer overflow or unallocated storage, in
production. Before someone is allowed to do the real thing, they need to
master the basics.
Fine, so you agree that the best solution is to hire good people and make
sure they know what they're doing?
The main risk where I work, is rather the "clever" insiders.
What do you mean by "clever"? Where I come from, it means "smart, bright,
intelligent" and is considered a compliment. If you mean someone who tries
to write difficult code to show off how well he can write difficult code
(instead of writing easy code that anyone could maintain), I wouldn't call
that "clever".