...
Code Block |
---|
|
/* In another source file */
#include <string.h>
void copy(char *dst, const char *src) {
if (!strcpy(dst, src)) {
/* Report error */
}
}
/* In this source file -- no copy prototype in scope */
void copy();
void g(const char *s) {
char buf[20];
copy(buf, s, sizeof buf); /* Violation */
/* ... */
} |
...
Code Block |
---|
|
/* In another source file */
#include <string.h>
void copy(char *dst, const char *src) {
if (!strcpy(dst, src) == 0) {
/* Report error */
}
}
/* Copy prototype in scope in this source file */
void copy(char *dst, const char *src);
void g(const char *s) {
char buf[20];
copy(buf, s);
/* ... */
}
|
...
Code Block |
---|
|
#include <fcntl.h>
void func(void) {
/* ... */
fd = open(ms, O_CREAT|O_EXCL|O_WRONLY|O_TRUNC, file_access_permissions);
if (fd == -1){
/* Handle error */
}
/* ... */
} |
Risk Assessment
Calling a function with incorrect arguments can result in unexpected or unintended program behavior.
...