aboutsummaryrefslogtreecommitdiff
path: root/slides/2018-software-security/sample/assignment-integer-overflow.c
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2024-10-15 15:35:20 +0200
committerRasmus Dahlberg <rasmus@rgdd.se>2024-10-15 15:35:45 +0200
commit76bae02bcd7d6b3ec9eea428e5e95da184a8dbfb (patch)
tree410ab71c78c99d35aecd46733958a5699cdf5204 /slides/2018-software-security/sample/assignment-integer-overflow.c
parent883a67439aff566962adafeb0385c6ae972073a3 (diff)
Rescue some slides from old private mono repos
Diffstat (limited to 'slides/2018-software-security/sample/assignment-integer-overflow.c')
-rw-r--r--slides/2018-software-security/sample/assignment-integer-overflow.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/slides/2018-software-security/sample/assignment-integer-overflow.c b/slides/2018-software-security/sample/assignment-integer-overflow.c
new file mode 100644
index 0000000..58c59b1
--- /dev/null
+++ b/slides/2018-software-security/sample/assignment-integer-overflow.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int get_int() {
+ int v; printf("Enter an integer: ");
+ scanf("%d", &v);
+ return v;
+}
+
+int main() {
+ int a=get_int(), b=get_int(), max=10;
+ if (a+b > max)
+ printf("%d+%d > %d\n", a, b, max);
+ else
+ printf("%d+%d <= %d\n", a, b, max);
+}