Oh boy, I sure do love writing C code!

I Hope I Don’t Encounter Any Buffer Overflows!

1
2
3
4
int main(void) {
    char buf[10] = "Hi, World";
    buf[10] = '!';
}

Ah, of course.

I Love Leaking Memory

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <stdlib.h>

int main(void) {
    int size = 1000;

    while (size >= 1) {
        if (!malloc(size)) {
            size /= 10;
        }
    }

    return EXIT_SUCCESS;    // :)
}

Hey at least we aren’t Java

1
2
3
4
5
6
7
8
package master;
//package main;

public class Master {
    public static void main(String[] args) {
        System.out.println("This is fine");
    }
}

Assembly be like

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
global _start

section .text

_start:
  mov rax, 1        ; write(
  mov rdi, 1        ;   STDOUT_FILENO,
  mov rsi, msg      ;   "Hello, world!\n",
  mov rdx, msglen   ;   sizeof("Hello, world!\n")
  syscall           ; );

  mov rax, 60       ; exit(
  mov rdi, 0        ;   EXIT_SUCCESS
  syscall           ; );

section .rodata
  msg: db "Hello, world!", 10
  msglen: equ $ - msg