From b7be2c5498fd1844daadd9e78aa031c60be9cb44 Mon Sep 17 00:00:00 2001 From: rose Date: Wed, 13 Aug 2025 01:28:16 +0200 Subject: Change chances for silly-malloc --- silly-malloc/README | 3 +-- silly-malloc/meow.c | 10 ---------- silly-malloc/teehee.c | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 silly-malloc/meow.c (limited to 'silly-malloc') diff --git a/silly-malloc/README b/silly-malloc/README index 0d26192..f5a0804 100644 --- a/silly-malloc/README +++ b/silly-malloc/README @@ -5,6 +5,5 @@ Randomly allocate less memory than wanted ## Usage ```bash gcc -fPIC -shared teehee.c -o teehee.so -gcc meow.c -o meow -LD_PRELOAD=./teehee.so ./meow +LD_PRELOAD=./teehee.so ``` diff --git a/silly-malloc/meow.c b/silly-malloc/meow.c deleted file mode 100644 index 88c7e88..0000000 --- a/silly-malloc/meow.c +++ /dev/null @@ -1,10 +0,0 @@ -#define _GNU_SOURCE -#include -#include - -int main () { - char *merow = malloc (9); - sprintf (merow, "meowmeow"); - printf ("%s\n", merow); - free (merow); -} diff --git a/silly-malloc/teehee.c b/silly-malloc/teehee.c index 635a413..ed92eb9 100644 --- a/silly-malloc/teehee.c +++ b/silly-malloc/teehee.c @@ -12,9 +12,9 @@ extern void *malloc (size_t size) { if (!real_malloc) return NULL; // lmao srand (time (NULL)); - int val = rand () % 3; + int val = (rand () % 2)+1; if (val > 1) { - long loss = rand () % (int) size; + long loss = (rand () % (int) size)+5; return real_malloc (size - loss); } else { return real_malloc (size); -- cgit v1.2.3