Dodano slajdy i pliki od prowadzącego
This commit is contained in:
parent
b092b9774f
commit
84d79a11d0
33 changed files with 469 additions and 0 deletions
BIN
C_secure_coding/SecC++.zip
Normal file
BIN
C_secure_coding/SecC++.zip
Normal file
Binary file not shown.
18
C_secure_coding/SecC++/examples/adresses.c
Normal file
18
C_secure_coding/SecC++/examples/adresses.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void foo(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int a = 12;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int b = 0;
|
||||||
|
char * a;
|
||||||
|
char * c;
|
||||||
|
strcpy(a, c);
|
||||||
|
|
||||||
|
printf("%p, %p, %p\n", &b, &a, foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
30
C_secure_coding/SecC++/examples/data_race.cpp
Normal file
30
C_secure_coding/SecC++/examples/data_race.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <chrono>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
int counter = 65535;
|
||||||
|
std::mutex mtx = {};
|
||||||
|
|
||||||
|
void worker(int delta) {
|
||||||
|
for (auto i = 0U; i < 100; ++i) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
|
// Zła praktyka! Zawsze rób to RAII!
|
||||||
|
// mtx.lock();
|
||||||
|
{ // Critical section
|
||||||
|
std::lock_guard<std::mutex> _(mtx);
|
||||||
|
counter += delta;
|
||||||
|
}
|
||||||
|
// mtx.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto t1 = std::thread(worker, 1);
|
||||||
|
auto t2 = std::thread(worker, -1);
|
||||||
|
|
||||||
|
t2.join();
|
||||||
|
t1.join();
|
||||||
|
assert(counter == 65535);
|
||||||
|
}
|
||||||
26
C_secure_coding/SecC++/examples/data_race_atomic.cpp
Normal file
26
C_secure_coding/SecC++/examples/data_race_atomic.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <chrono>
|
||||||
|
#include <mutex>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
std::atomic<int> counter = 65535;
|
||||||
|
|
||||||
|
void worker(int delta) {
|
||||||
|
for (auto i = 0U; i < 100; ++i) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
|
counter.fetch_add(delta, std::memory_order_release);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << "int is atomic? " << std::atomic<int>{}.is_lock_free() << '\n';
|
||||||
|
|
||||||
|
auto t1 = std::thread(worker, 1);
|
||||||
|
auto t2 = std::thread(worker, -1);
|
||||||
|
|
||||||
|
t2.join();
|
||||||
|
t1.join();
|
||||||
|
assert(counter == 65535);
|
||||||
|
}
|
||||||
10
C_secure_coding/SecC++/examples/linking/function.c
Normal file
10
C_secure_coding/SecC++/examples/linking/function.c
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "function.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void foo(void) {
|
||||||
|
printf("Hello. I'm foo().\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void bar(void) {
|
||||||
|
printf("Hello. I'm bar().\n");
|
||||||
|
}
|
||||||
4
C_secure_coding/SecC++/examples/linking/function.h
Normal file
4
C_secure_coding/SecC++/examples/linking/function.h
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void foo(void);
|
||||||
|
void bar(void);
|
||||||
7
C_secure_coding/SecC++/examples/linking/main.c
Normal file
7
C_secure_coding/SecC++/examples/linking/main.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "function.h"
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
//foo();
|
||||||
|
bar();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
9
C_secure_coding/SecC++/examples/main.c
Normal file
9
C_secure_coding/SecC++/examples/main.c
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int * data = malloc(10000);
|
||||||
|
(void) data;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
16
C_secure_coding/SecC++/examples/mario.c
Normal file
16
C_secure_coding/SecC++/examples/mario.c
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int x = 0;
|
||||||
|
printf("%d, %d\n", x, ++x);
|
||||||
|
float b = 123.4f;
|
||||||
|
(void) b;
|
||||||
|
|
||||||
|
float a = 0.1;
|
||||||
|
|
||||||
|
if (a > 0.1) {
|
||||||
|
printf("Ups!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
61
C_secure_coding/SecC++/examples/move_sem.cpp
Normal file
61
C_secure_coding/SecC++/examples/move_sem.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class X {
|
||||||
|
public:
|
||||||
|
explicit X(const std::string& name)
|
||||||
|
: name_ptr(new std::string(name)) {
|
||||||
|
std::cout << "Construct X name= " << *name_ptr << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// non copyable
|
||||||
|
X(const X& x) = delete;
|
||||||
|
X& operator=(const X& x) = delete;
|
||||||
|
|
||||||
|
void info() const {
|
||||||
|
std::cout << "info() in X\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
X(X&& x) {
|
||||||
|
std::cout << "Move construct name = " << *(x.name_ptr) << '\n';
|
||||||
|
name_ptr = x.name_ptr;
|
||||||
|
x.name_ptr = nullptr;
|
||||||
|
}
|
||||||
|
X& operator=(X&& x) {
|
||||||
|
std::cout << "Move operator= name = " << *(x.name_ptr) << '\n';
|
||||||
|
if (name_ptr != nullptr) {
|
||||||
|
delete name_ptr;
|
||||||
|
}
|
||||||
|
name_ptr = x.name_ptr;
|
||||||
|
x.name_ptr = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~X() {
|
||||||
|
std::cout << "Destruct name= ";
|
||||||
|
if (name_ptr != nullptr) {
|
||||||
|
std::cout << *name_ptr;
|
||||||
|
} else {
|
||||||
|
std::cout << "nullptr";
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
// Nadmiarowe i edukacyjne
|
||||||
|
if (name_ptr != nullptr) {
|
||||||
|
delete name_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::string * name_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
void foo(X&& my_x) {
|
||||||
|
std::cout << "In foo()\n";
|
||||||
|
my_x.info();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto x1 = X("DNA Myszy");
|
||||||
|
auto x2 = std::move(x1);
|
||||||
|
|
||||||
|
foo(std::move(x2));
|
||||||
|
std::cout << "After foo()\n";
|
||||||
|
}
|
||||||
53
C_secure_coding/SecC++/examples/move_sem_improv.cpp
Normal file
53
C_secure_coding/SecC++/examples/move_sem_improv.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class X {
|
||||||
|
public:
|
||||||
|
explicit X(const std::string& name)
|
||||||
|
: name_ptr(std::make_unique<std::string>(name)) {
|
||||||
|
std::cout << "Construct X name= " << *name_ptr << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// non copyable
|
||||||
|
X(const X& x) = delete;
|
||||||
|
X& operator=(const X& x) = delete;
|
||||||
|
|
||||||
|
void info() const {
|
||||||
|
std::cout << "info() in X\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
X(X&& x) {
|
||||||
|
std::cout << "Move construct name = " << *(x.name_ptr) << '\n';
|
||||||
|
name_ptr = std::move(x.name_ptr);
|
||||||
|
}
|
||||||
|
X& operator=(X&& x) {
|
||||||
|
std::cout << "Move operator= name = " << *(x.name_ptr) << '\n';
|
||||||
|
name_ptr = std::move(x.name_ptr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~X() {
|
||||||
|
std::cout << "Destruct name= ";
|
||||||
|
if (name_ptr != nullptr) {
|
||||||
|
std::cout << *name_ptr;
|
||||||
|
} else {
|
||||||
|
std::cout << "nullptr";
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::unique_ptr<std::string> name_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
void foo(X&& my_x) {
|
||||||
|
std::cout << "In foo()\n";
|
||||||
|
my_x.info();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto x1 = X("DNA Myszy");
|
||||||
|
auto x2 = std::move(x1);
|
||||||
|
|
||||||
|
foo(std::move(x2));
|
||||||
|
std::cout << "After foo()\n";
|
||||||
|
}
|
||||||
3
C_secure_coding/SecC++/examples/myrand.c
Normal file
3
C_secure_coding/SecC++/examples/myrand.c
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
int rand(void) {
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
24
C_secure_coding/SecC++/examples/option.cpp
Normal file
24
C_secure_coding/SecC++/examples/option.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <optional>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
std::optional<int> my_div(int a, int b) {
|
||||||
|
if (b == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
//return std::make_optional<int>(a / b);
|
||||||
|
return {a / b};
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto opt = my_div(16, 0);
|
||||||
|
//if (opt.has_value()) {
|
||||||
|
if (opt) {
|
||||||
|
std::cout << "Correct!\n";
|
||||||
|
//std::cout << opt.value() << '\n';
|
||||||
|
std::cout << *opt << '\n';
|
||||||
|
} else {
|
||||||
|
std::cout << "Incorrect!\n";
|
||||||
|
// To jest terroryzm!
|
||||||
|
std::cout << *opt << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
13
C_secure_coding/SecC++/examples/prog1.c
Normal file
13
C_secure_coding/SecC++/examples/prog1.c
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
// To jest niebezpieczne!
|
||||||
|
srand(time(0));
|
||||||
|
|
||||||
|
int a = rand();
|
||||||
|
printf("%d\n", a);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
51
C_secure_coding/SecC++/examples/shr_ptr.cpp
Normal file
51
C_secure_coding/SecC++/examples/shr_ptr.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
class Airplane {
|
||||||
|
public:
|
||||||
|
explicit Airplane(const std::string & name_)
|
||||||
|
: name{name_} {
|
||||||
|
std::cout << "Construct Airplane name = " << name << '\n';
|
||||||
|
}
|
||||||
|
const std::string & get_name() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
~Airplane() {
|
||||||
|
std::cout << "Destruct Airplane name = " << name << '\n';
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
const std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
// std::unique_ptr<Airplane> process_airplane(std::unique_ptr<Airplane> airplane);
|
||||||
|
//
|
||||||
|
// u_p_airplane = process_airpalne(std::move(u_p_airplane));
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::shared_ptr<Airplane> a1;
|
||||||
|
auto a2 = std::make_shared<Airplane>("DC8");
|
||||||
|
|
||||||
|
a1 = a2;
|
||||||
|
|
||||||
|
std::cout << a1->get_name() << '\n';
|
||||||
|
std::cout << a2->get_name() << '\n';
|
||||||
|
|
||||||
|
std::cout << "Count a1: " << a1.use_count() << " a2: " << a2.use_count() << '\n';
|
||||||
|
|
||||||
|
std::shared_ptr<Airplane> a3;
|
||||||
|
a3 = std::move(a1);
|
||||||
|
|
||||||
|
std::cout << "Count a1: " << a1.use_count()
|
||||||
|
<< " a2: " << a2.use_count() << " a3: " << a3.use_count() << '\n';
|
||||||
|
|
||||||
|
auto a4 = std::make_unique<Airplane>("Mig21");
|
||||||
|
|
||||||
|
std::shared_ptr<Airplane> a5;
|
||||||
|
a5 = std::move(a4);
|
||||||
|
|
||||||
|
u_p = std::move(s_p);
|
||||||
|
}
|
||||||
|
|
||||||
18
C_secure_coding/SecC++/examples/struct.c
Normal file
18
C_secure_coding/SecC++/examples/struct.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
struct X {
|
||||||
|
int data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct X process(void) {
|
||||||
|
struct X x;
|
||||||
|
x.data = 42;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
struct X x = process();
|
||||||
|
printf("%d\n", x.data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
16
C_secure_coding/SecC++/examples/taint.cpp
Normal file
16
C_secure_coding/SecC++/examples/taint.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
enum class DataType {
|
||||||
|
Taint,
|
||||||
|
NotTaint
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class DataType>
|
||||||
|
struct Data {
|
||||||
|
int payload[200];
|
||||||
|
};
|
||||||
|
|
||||||
|
Data<NotTaint> foo(Data<Taint> data);
|
||||||
|
|
||||||
|
void foo(Data<NotTaint> data);
|
||||||
|
|
||||||
|
|
||||||
50
C_secure_coding/SecC++/examples/unuq_ptr.cpp
Normal file
50
C_secure_coding/SecC++/examples/unuq_ptr.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
class Airplane {
|
||||||
|
public:
|
||||||
|
explicit Airplane(const std::string & name_)
|
||||||
|
: name{name_} {
|
||||||
|
std::cout << "Construct Airplane name = " << name << '\n';
|
||||||
|
}
|
||||||
|
const std::string & get_name() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
~Airplane() {
|
||||||
|
std::cout << "Destruct Airplane name = " << name << '\n';
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
const std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
void info(std::unique_ptr<Airplane> ptr) {
|
||||||
|
std::cout << "In info()\n";
|
||||||
|
std::cout << ptr->get_name() << '\n';
|
||||||
|
std::cout << "End of info()\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::unique_ptr<Airplane> a1;
|
||||||
|
{
|
||||||
|
auto a2 = std::make_unique<Airplane>("F22");
|
||||||
|
|
||||||
|
a1 = std::move(a2);
|
||||||
|
|
||||||
|
std::cout << "End of scope\n";
|
||||||
|
}
|
||||||
|
std::cout << "Out of scope\n";
|
||||||
|
|
||||||
|
std::cout << a1->get_name() << '\n';
|
||||||
|
|
||||||
|
auto a3 = std::make_unique<Airplane>("Pirat");
|
||||||
|
|
||||||
|
std::cout << "Before info()\n";
|
||||||
|
info(std::move(a3));
|
||||||
|
|
||||||
|
std::cout << "After info()\n";
|
||||||
|
|
||||||
|
std::cout << "End main()\n";
|
||||||
|
}
|
||||||
|
|
||||||
BIN
C_secure_coding/SecC++/notes/ptr_container.png
Normal file
BIN
C_secure_coding/SecC++/notes/ptr_container.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 327 KiB |
BIN
C_secure_coding/SecC++/notes/ptr_struct.png
Normal file
BIN
C_secure_coding/SecC++/notes/ptr_struct.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 403 KiB |
BIN
C_secure_coding/SecC++/notes/pure.png
Normal file
BIN
C_secure_coding/SecC++/notes/pure.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 KiB |
BIN
C_secure_coding/SecC++/notes/sec_rings.png
Normal file
BIN
C_secure_coding/SecC++/notes/sec_rings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 366 KiB |
BIN
C_secure_coding/SecC++/notes/sec_surface.png
Normal file
BIN
C_secure_coding/SecC++/notes/sec_surface.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 322 KiB |
BIN
C_secure_coding/SecC++/slides/C90_C99_Przegląd_mechanizmów.pdf
Normal file
BIN
C_secure_coding/SecC++/slides/C90_C99_Przegląd_mechanizmów.pdf
Normal file
Binary file not shown.
BIN
C_secure_coding/SecC++/slides/MITRE.pdf
Normal file
BIN
C_secure_coding/SecC++/slides/MITRE.pdf
Normal file
Binary file not shown.
BIN
C_secure_coding/SecC++/slides/Modele_Bezpieczeństwa.pdf
Normal file
BIN
C_secure_coding/SecC++/slides/Modele_Bezpieczeństwa.pdf
Normal file
Binary file not shown.
BIN
C_secure_coding/SecC++/slides/Modelowanie_Zagrożeń.pdf
Normal file
BIN
C_secure_coding/SecC++/slides/Modelowanie_Zagrożeń.pdf
Normal file
Binary file not shown.
27
C_secure_coding/SecC++/wrap_function/Makefile
Normal file
27
C_secure_coding/SecC++/wrap_function/Makefile
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Przykład "owinięcia" (wrap) / sastąpienia
|
||||||
|
# pojedynczej funkcji przez linker
|
||||||
|
# Uwaga na zamierzone włączenie #include "foo.c"
|
||||||
|
# w test/foo.c
|
||||||
|
.PHONY := clean
|
||||||
|
|
||||||
|
CC := gcc
|
||||||
|
|
||||||
|
CFLAGS := -Wall -Wextra -pedantic
|
||||||
|
LDFLAGS :=
|
||||||
|
OBJS := main.o foo.o
|
||||||
|
|
||||||
|
WRAP_CFLAGS := $(CFLAGS)
|
||||||
|
WRAP_LDFLAGS := $(LD_FLAGS) -Wl,-wrap=foo
|
||||||
|
WRAP_OBJS := main.o
|
||||||
|
WRAP_SRCDIR := tests
|
||||||
|
|
||||||
|
all: main wrap
|
||||||
|
|
||||||
|
main: $(OBJS)
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
wrap: $(WRAP_OBJS)
|
||||||
|
$(CC) $(WRAP_LDFLAGS) -o wrap $^ $(WRAP_SRCDIR)/foo.c -I$(WRAP_SRCDIR)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f main wrap $(OBJS) $(WRAP_OBJS) > /dev/null 2>&1
|
||||||
8
C_secure_coding/SecC++/wrap_function/foo.c
Normal file
8
C_secure_coding/SecC++/wrap_function/foo.c
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "foo.h"
|
||||||
|
|
||||||
|
static int value = 42;
|
||||||
|
|
||||||
|
void foo() {
|
||||||
|
printf("Original foo(), value = %d.\n", value);
|
||||||
|
}
|
||||||
3
C_secure_coding/SecC++/wrap_function/foo.h
Normal file
3
C_secure_coding/SecC++/wrap_function/foo.h
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void foo(void);
|
||||||
6
C_secure_coding/SecC++/wrap_function/main.c
Normal file
6
C_secure_coding/SecC++/wrap_function/main.c
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "foo.h"
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
9
C_secure_coding/SecC++/wrap_function/tests/foo.c
Normal file
9
C_secure_coding/SecC++/wrap_function/tests/foo.c
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "../foo.c" /* !!! */
|
||||||
|
#include "foo.h"
|
||||||
|
|
||||||
|
void __wrap_foo(void) {
|
||||||
|
printf("Wrap foo(), value = %d.\n", value);
|
||||||
|
printf(" ");
|
||||||
|
__real_foo();
|
||||||
|
}
|
||||||
7
C_secure_coding/SecC++/wrap_function/tests/foo.h
Normal file
7
C_secure_coding/SecC++/wrap_function/tests/foo.h
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern int value;
|
||||||
|
|
||||||
|
void foo(void);
|
||||||
|
void __real_foo(void);
|
||||||
|
void __wrap_foo(void);
|
||||||
Loading…
Reference in a new issue