This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |