From 0f891689362064fd027701e27eeb2e1a8e903f97 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 31 Mar 2023 06:56:17 -0700 Subject: [PATCH] Fix zero arg segfault in 2020/burton I did not fix the strange output when more than one arg is specified nor do I think I should. I did not update Dave's comment that it will segfault on zero args nor do I think I should (instead I updated the To run section like I've done with the many others I've fixed). --- 2020/burton/README.md | 12 ++++++++---- 2020/burton/prog.c | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/2020/burton/README.md b/2020/burton/README.md index d7800de98..391b014ad 100644 --- a/2020/burton/README.md +++ b/2020/burton/README.md @@ -1,8 +1,8 @@ # Best one-liner -Dave Burton - -Twitter: @lv2jmp + Dave Burton + + Twitter: @lv2jmp ## To build: @@ -16,7 +16,11 @@ make ./prog arg ... ``` -NOTE: this entry will dump core if you do not specify an argument. +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this entry not +segfault when no arg is specified though he notes that the author says it will +segfault on zero args. He did NOT fix the strange results when more than one arg +is specified. Thank you Cody for your assistance! + ## Try: diff --git a/2020/burton/prog.c b/2020/burton/prog.c index 60be69261..67c915521 100644 --- a/2020/burton/prog.c +++ b/2020/burton/prog.c @@ -1 +1 @@ -int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);} +int main(int b,char**i){if(1[i]){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}}