>this scares the rustranny
#include
#include
#include
int main(void) {
char* msg = malloc(sizeof(char) * 16);
strcpy(msg, "rustrannies btfo");
printf("%s", msg);
}
why are rust trannies so scared of malloc?
>this scares the rustranny
#include
#include
#include
int main(void) {
char* msg = malloc(sizeof(char) * 16);
strcpy(msg, "rustrannies btfo");
printf("%s", msg);
}
why are rust trannies so scared of malloc?
what is a malloc
>malloc(sizeof(char) * 16)
>rustrannies btfo
Nice!
printf is unstable
>inb4 hello worlder discussing programming languages
You are missing one byte for the null terminator. Your program is invalid according to the standard.
>programming in C
enjoy your ubs
fbbp
HAHAHAHAHAHAHAHAHAHA OH NO NO NO NO NO
one byte overflow, nice.
"rustrannies btfo" has 16 characters, it's right you retard
this also scares the rustreannys
section .text
extern printf
global main
main:
push ebp
mov ebp, esp
push DWORD [str+4]
push DWORD [str]
push str
call printf
xor eax, eax
mov esp, ebp
leave
ret
section .data
str: db 'memelang: %d %d',13,10,0
output:
>memelang: 1701668205 1735287148
build:
..\..\..\..\global_tools\nasm -felf rustardbtfo.asm
..\..\..\..\global_tools\tcc\tcc.exe -m32 rustardbtfo.o
rustardbtfo.exe
>he doesn't know that sizeof(char) is guaranteed to be 1
>he uses printf("%s", msg) instead of puts(msg)
16 characters + 1 null terminator. Have you ever programmed in C?
>enjoy your ubs
?
OP absolutely felted, his program would only work if the printf() was replaced by
for (int i = 0; i < 16; i++) {
printf("%c", mgs[i]);
}
The %s REQUIRES null-termination or it will carry on printing whatever is in the memory until it reaches a null-byte
iTODDLERS BTFO
>didnt deallocate memory
10/10
where's your free
>he makes all of these irrelevant points but still doesn't know the meaning of null-terminated strings
Also the program is missing a return statement, so the behaviour is undefined.
>not deallocating memory
>overflowing
>no return statement
a canaanite infant-eating owl god worshipped by kikes and nwo masonic faggots…there’s an enormous stone statue of it at bohemian grove
I'm a C programmer but the OP BTFO'd himself, and actually makes a good case for using Rust.
>deallocating
OS does that for you
> overflowing
only if malloc fails
> no return statement
not needed in older C.
the absolute state of cniles
$ nano fag.c
$ cat fag.c
#include
#include
#include
int main(void) {
char* msg = malloc(sizeof(char) * 16);
strcpy(msg, "rustrannies btfo");
printf("%s", msg);
}
$ gcc fag.c
fag.c: In function ‘main’:
fag.c:7:3: warning: ‘__builtin_memcpy’ writing 17 bytes into a region of size 16 overflows the destination [-Wstringop-overflow=]
7 | strcpy(msg, "rustrannies btfo");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fag.c:6:15: note: destination object of size 16 allocated by ‘malloc’
6 | char* msg = malloc(sizeof(char) * 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
literally 5 lines and you already got a buffer overflow
Based C-Chad tranny destroyer.
just disable warnings? they are useless anyway
it compiles and runs just fine