Skip to content

Instantly share code, notes, and snippets.

View saidwho12's full-sized avatar

Saïd Metiche saidwho12

  • 20:40 (UTC -04:00)
View GitHub Profile
@rexim
rexim / main.rs
Last active April 3, 2024 19:40
The Most Memory Safe Buffer Overflow in Rust!
// The Most Memory Safe Buffer Overflow in Rust!
//
// Consider all the code below under Public Domain
//
// How to build:
// $ rustc main.rs
//
// Wrong password:
// $ printf "hello\n" | ./main
//
@vurtun
vurtun / ui.c
Last active July 26, 2021 19:55
struct gui_bnd {int min, mid, max, ext;};
struct gui_box {
struct gui_bnd x;
struct gui_bnd y;
};
#define gui_box(x,y,w,h) (struct gui_box){{x,x+(w>>1),x+w,w},{y,y+(h>>1),y+h,h}}
#define gui_min_max(a,b) (struct gui_bnd){a,a+((b-a)>>1),b,b-a}
#define gui_min_ext(m,e) (struct gui_bnd){m,m+(e>>1),m+e,e}
#define gui_max_ext(m,e) (struct gui_bnd){m-e,m-(e>>1),m,e}
#define gui_mid_min(c,m) (struct gui_bnd){m,c,m+c-m,(m-c)<<1}