From 9f4f0981e0a03033a21fa2cd7d2f11d56a636c4f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 01:52:42 -0700 Subject: [PATCH 01/17] Fix 1984/laman if no arg specified As the definition of INABIAF changed, again, and since it took no more than ten seconds to fix, I have fixed this entry. As the thanks file was updated for this some other things that had been left out were also fixed at the same time as these were already in the file but not committed. There was also a typo fix in there. --- 1984/laman/README.md | 11 ----------- 1984/laman/laman.c | 4 ++-- bugs.md | 31 +++++++++---------------------- thanks-for-fixes.md | 20 ++++++++++++++++---- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/1984/laman/README.md b/1984/laman/README.md index 6c138c1d6..93382da10 100644 --- a/1984/laman/README.md +++ b/1984/laman/README.md @@ -10,17 +10,6 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [1984 laman in bugs.md](/bugs.md#1984-laman). - - ## To use: ```sh diff --git a/1984/laman/laman.c b/1984/laman/laman.c index 758e4480c..eba619be4 100644 --- a/1984/laman/laman.c +++ b/1984/laman/laman.c @@ -1,5 +1,5 @@ a[900]; b;c;d=1 ;e=1;f; g;h;O; main(k, -l)char* *l;{g= atoi(* ++l); for(k= +l)char* *l;{if(k>1) {g=atoi(* ++l); for(k= 0;k*k< g;b=k ++>>1) ;for(h= 0;h*h<= g;++h); --h;c=( (h+=g>h *(h+1)) -1)>>1; while(d <=g){ ++O;for (f=0;f< O&&d<=g @@ -9,4 +9,4 @@ while(d <=g){ ++O;for (f=0;f< O&&d<=g b){if(b Date: Mon, 30 Oct 2023 04:34:51 -0700 Subject: [PATCH 02/17] Fix 2006/stewart - check if FILE * == NULL --- 2006/stewart/README.md | 16 ---------------- 2006/stewart/stewart.c | 1 + thanks-for-fixes.md | 5 +++++ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/2006/stewart/README.md b/2006/stewart/README.md index 8154aa3f1..e1a46c56e 100644 --- a/2006/stewart/README.md +++ b/2006/stewart/README.md @@ -10,17 +10,6 @@ make ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [2006 stewart in bugs.md](/bugs.md#2006-stewart). - - ## To use: ```sh @@ -48,11 +37,6 @@ where `FILE` is one of: spirals4 squares stars stars2 tree tree2 tree3 tree4 triangle -### INABIAF - it's not a bug it's a feature! :-) - -This program will very likely crash or do something funny if the file does not -exist or cannot be opened. - ## Judges' remarks: Note the interesting choice of using a `#define` in the output. diff --git a/2006/stewart/stewart.c b/2006/stewart/stewart.c index 02103ec9e..8b27aec4b 100644 --- a/2006/stewart/stewart.c +++ b/2006/stewart/stewart.c @@ -20,6 +20,7 @@ int main(int c,char**o) Z(v,6)=(long)malloc(Z(v,0)); memset((void*)Z(v,6),0,Z(v,0)); Z(v,13)=(long)fopen(o[3],"r"); + if(F(v,13)==NULL)P("file doesn't exist\n"), exit(1); fscanf(F(v,13),"%ld",(long*)Y(v,3)); Z(v,8)=(long)malloc(050+Z(v,3)*070); Z(Z(v,8),0)=Z(v,3); diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index d0fca688d..9e5151303 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2154,6 +2154,11 @@ Since the author suggested that the lack of certain `#include`s might break the program in some systems he added `-include ...` to the Makefile as well. +## [2006/stewart](2006/stewart/stewart.c) ([README.md](2006/stewart/README.md])) + +Cody fixed it so that if the file cannot be opened it exits rather than trying +to read from the file. + ## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md])) Cody fixed a segfault in this program which was making it fail to work under From 8946cff4fad9cb924832305c60efa79f0d08f21d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:00:52 -0700 Subject: [PATCH 03/17] Fix 2001/schweikh - check args This was not documented. The limitations have not been addressed as they were documented. The bugs.md and README.md have been updated for this. --- 2001/schweikh/README.md | 2 +- 2001/schweikh/schweikh.c | 2 +- bugs.md | 25 +++---------------------- thanks-for-fixes.md | 6 ++++++ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/2001/schweikh/README.md b/2001/schweikh/README.md index dbd19f061..af487a8fd 100644 --- a/2001/schweikh/README.md +++ b/2001/schweikh/README.md @@ -16,7 +16,7 @@ make The current status of this entry is: ``` -STATUS: known bug - please help us fix +STATUS: INABIAF - please **DO NOT** fix ``` For more detailed information see [2001 schweikh in bugs.md](/bugs.md#2001-schweikh). diff --git a/2001/schweikh/schweikh.c b/2001/schweikh/schweikh.c index b24af7599..e0dd12282 100644 --- a/2001/schweikh/schweikh.c +++ b/2001/schweikh/schweikh.c @@ -1 +1 @@ -main(int c,char**v){return!m(v[1],v[2]);}m(char*s,char*t){return*t-42?*s?63==*t|*s==*t&&m(s+1,t+1):!*t:m(s,t+1)||*s&&m(s+1,t);} +main(int c,char**v){return c<3?1:!m(v[1],v[2]);}m(char*s,char*t){return*t-42?*s?63==*t|*s==*t&&m(s+1,t+1):!*t:m(s,t+1)||*s&&m(s+1,t);} diff --git a/bugs.md b/bugs.md index 401783f9f..dc2b412dc 100644 --- a/bugs.md +++ b/bugs.md @@ -1342,22 +1342,15 @@ This program will very likely crash or do something else without an arg. If you want to try and fix this (mis)feature, you are welcome to try. -## 2001 schweikh - -### STATUS: known bug - please help us fix +### STATUS: INABIAF - please **DO NOT** fix ### Source code: [2001/schweikh/schweikh.c](2001/schweikh/schweikh.c) ### Information: [2001/schweikh/README.md](2001/schweikh/README.md) -This program will very likely crash or do something else if you do not give it -two args. - -Note also that the glob pattern must match the whole string. See the author's -comments for details and a workaround. +The glob pattern must match the whole string. See the author's comments for +details and a workaround. There's also no way to escape meta characters. -If you want to try and fix this (mis)feature, you are welcome to try. - # 2002 @@ -1569,18 +1562,6 @@ Fixing the (Mis)feature is likely to be a difficult challenge. You are welcome to try and fix it if you can! -## 2006 stewart - -### STATUS: known bug - please help us fix -### Source code: [2006/stewart/stewart.c](2006/stewart/stewart.c) -### Information: [2006/stewart/README.md](2006/stewart/README.md) - -This program will very likely crash or do something funny if the file does not -exist or cannot be opened. - -If you want to try and fix this (mis)feature, you are welcome to try. - - ## 2006 toledo2 ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 9e5151303..3d4252517 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1830,6 +1830,12 @@ the paddles move even when holding down the movement keys. Cody also provided an alternate version which lets you use the arrow keys on your keyboard instead of the more awkward '`,`' and '`.`'. +## [2001/schweikh](2001/schweikh/schweikh.c) ([README.md](2001/schweikh/README.md])) + +Cody fixed this to not crash if not enough args as this was not documented by +the author. The other problems are documented so were not fixed. See +README.md for details. + ## [2001/westley](2001/westley/westley.c) ([README.md](2001/westley/README.md])) From 70cc096f6e346a4a4dff5a62734775fd67b5543c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:06:03 -0700 Subject: [PATCH 04/17] Fix 2001/ollinger - check args --- 2001/ollinger/ollinger.c | 1 + bugs.md | 8 -------- thanks-for-fixes.md | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/2001/ollinger/ollinger.c b/2001/ollinger/ollinger.c index 318773a22..29d45a4d0 100644 --- a/2001/ollinger/ollinger.c +++ b/2001/ollinger/ollinger.c @@ -11,6 +11,7 @@ char e[]="**3H[`mr25\ int main(int j,char *k[]) { int a,b,c,d,g,h,i=19; + if (j<2)exit(1); printf(" "); for(g=0[f=(char *)calloc(80+(h=atoi(1[k])),1)]=1; g<=h; g++) { if ((g>30)&&(f[i-2]+f[i-1]!=0)) i++; diff --git a/bugs.md b/bugs.md index dc2b412dc..750254b9d 100644 --- a/bugs.md +++ b/bugs.md @@ -1333,14 +1333,6 @@ set. In other words both have to be ASCII or EBCDIC - not one of each. ## 2001 ollinger -### STATUS: known bug - please help us fix -### Source code: [2001/ollinger/ollinger.c](2001/ollinger/ollinger.c) -### Information: [2001/ollinger/README.md](2001/ollinger/README.md0 - -This program will very likely crash or do something else without an arg. - -If you want to try and fix this (mis)feature, you are welcome to try. - ### STATUS: INABIAF - please **DO NOT** fix ### Source code: [2001/schweikh/schweikh.c](2001/schweikh/schweikh.c) diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 3d4252517..00be616fe 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1830,6 +1830,10 @@ the paddles move even when holding down the movement keys. Cody also provided an alternate version which lets you use the arrow keys on your keyboard instead of the more awkward '`,`' and '`.`'. +## [2001/ollinger](2001/ollinger/ollinger.c) ([README.md](2001/ollinger/README.md)) + +Cody fixed to not crash if not enough args, exiting 1 instead. + ## [2001/schweikh](2001/schweikh/schweikh.c) ([README.md](2001/schweikh/README.md])) Cody fixed this to not crash if not enough args as this was not documented by From 51d1e9e4c467a77c0dd82a7c4e211cc67fb13002 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:10:20 -0700 Subject: [PATCH 05/17] Additional fix 2001/cheong - check args --- 2001/cheong/README.md | 16 ---------------- 2001/cheong/cheong.c | 2 +- bugs.md | 11 ----------- thanks-for-fixes.md | 1 + 4 files changed, 2 insertions(+), 28 deletions(-) diff --git a/2001/cheong/README.md b/2001/cheong/README.md index 48b019dc1..d2512f4f7 100644 --- a/2001/cheong/README.md +++ b/2001/cheong/README.md @@ -11,28 +11,12 @@ US\ make ``` - -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [2001 cheong in bugs.md](/bugs.md#2001-cheong). - - ## To use: ```sh ./cheong digits ``` -### INABIAF - it's not a bug it's a feature! :-) - -This program will very likely crash or do something different without an arg. - ## Try: diff --git a/2001/cheong/cheong.c b/2001/cheong/cheong.c index 97fef5f18..e229488ba 100644 --- a/2001/cheong/cheong.c +++ b/2001/cheong/cheong.c @@ -11,4 +11,4 @@ c=o+ (D[I]+82)%10-(I>l/2)* :!(o=pain(c/10,O,I-1))*((c+999 )%10-(D[I]+92)%10);}return o;} int main(int o,char **O) { -return pain(o, O, l); } +return o>1?pain(o, O, l):1; } diff --git a/bugs.md b/bugs.md index 750254b9d..944c760c9 100644 --- a/bugs.md +++ b/bugs.md @@ -1262,17 +1262,6 @@ and it can be run by itself for fun in modern systems, which was not possible before the fixes there. -## 2001 cheong - -### STATUS: known bug - please help us fix -### Source code: [2001/cheong/cheong.c](2001/cheong/cheong.c) -### Information: [2001/cheong/README.md](2001/cheong/README.md) - -This program will very likely crash or do something different without an arg. - -If you want to try and fix this (mis)feature, you are welcome to try. - - ## 2001 dgbeards ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 00be616fe..8c8300fbe 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1751,6 +1751,7 @@ letter word that would match the format and because it's pain that clang forces this. :-) This fix makes a point of the author's notes on portability no longer valid, btw. +He also fixed it to check the number of args. ## [2001/coupard](2001/coupard/coupard.c) ([README.md](2001/coupard/README.md])) From d629239eef3a93bc25b933e03e3d301c4786dcf1 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:41:15 -0700 Subject: [PATCH 06/17] Fix 1994/horton - check args --- 1994/horton/Makefile | 4 ++-- 1994/horton/README.md | 17 ----------------- 1994/horton/horton.c | 2 +- bugs.md | 12 ------------ thanks-for-fixes.md | 6 ++++++ 5 files changed, 9 insertions(+), 32 deletions(-) diff --git a/1994/horton/Makefile b/1994/horton/Makefile index 277c6ef4d..1ec5f9a7b 100644 --- a/1994/horton/Makefile +++ b/1994/horton/Makefile @@ -59,11 +59,11 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DE='exit(1)' -DA=argc # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include stdlib.h # Optimization # diff --git a/1994/horton/README.md b/1994/horton/README.md index 9a8b4ef04..d4e7ba0ed 100644 --- a/1994/horton/README.md +++ b/1994/horton/README.md @@ -11,17 +11,6 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [1994 horton in bugs.md](/bugs.md#1994-horton). - - ## To use: ```sh @@ -30,12 +19,6 @@ For more detailed information see [1994 horton in bugs.md](/bugs.md#1994-horton) `A`, `B`, `C` and `D` are numeric arguments. -### INABIAF - it's not a bug it's a feature! :-) - -Running this program without enough args will very likely crash or do something -else. - -## Try: ```sh ./horton 3 2 1 0 diff --git a/1994/horton/horton.c b/1994/horton/horton.c index 5e243facc..7ffae0aad 100644 --- a/1994/horton/horton.c +++ b/1994/horton/horton.c @@ -1,6 +1,6 @@ #define S(r, c) f[r][c] = 1; -char f[96][160]; main(argc, argv) char **argv; { double x, y, atof(); int +char f[96][160]; main(argc, argv) char **argv; {if(A<5)E;double x, y; int r , c , bi , diff --git a/bugs.md b/bugs.md index 944c760c9..7df5d6f1e 100644 --- a/bugs.md +++ b/bugs.md @@ -832,18 +832,6 @@ An alternate version, however, does exist. See the README.md file for details. # 1994 -## 1994 horton - -### STATUS: known bug - please help us fix -### Source code: [1994/horton/horton.c](1994/horton/horton.c) -### Information: [1994/horton/README.md](1994/horton/README.md) - -If not enough args are specified this program will likely crash or do something -else. - -If you want to try and fix this (mis)feature, you are welcome to try. - - ## 1994 ldb ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 8c8300fbe..278636b9f 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1289,6 +1289,12 @@ arg (as it was 0 at file scope already this is perfectly fine and it means there's no need to cast it to an int in the function call though that would also work). +## [1994/horton](1994/horton/horton.c) ([README.md](1994/horton/README.md)) + +Cody fixed this to check that four args were specified. With the use of the C +pre-processor macro and inclusion of stdlib.h in the Makefile the layout of the +source is exactly the same column width and no additional lines were added. + ## [1994/ldb](1994/ldb/ldb.c) ([README.md](1994/ldb/README.md])) From 641ddafe2adea68998449235e5650981e8ce329e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:45:19 -0700 Subject: [PATCH 07/17] Fix 1993/plummer - check args --- 1993/plummer/README.md | 16 ---------------- 1993/plummer/plummer.alt.c | 2 +- 1993/plummer/plummer.c | 2 +- bugs.md | 12 ------------ thanks-for-fixes.md | 8 +++++--- 5 files changed, 7 insertions(+), 33 deletions(-) diff --git a/1993/plummer/README.md b/1993/plummer/README.md index c0a9f3ff0..2ea47e606 100644 --- a/1993/plummer/README.md +++ b/1993/plummer/README.md @@ -13,17 +13,6 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [1993 plummer in bugs.md](/bugs.md#1993-plummer). - - ## To use: ```sh @@ -69,11 +58,6 @@ make clobber CDEFINE="-DZ=50" alt ./plummer.alt xyzzyzzyx 5555 ``` -### INABIAF - it's not a bug it's a feature :-) - -This entry will very likely crash or do something else if you run it without -enough args. - ## Judges' remarks: diff --git a/1993/plummer/plummer.alt.c b/1993/plummer/plummer.alt.c index 6bb7da8ac..e978e9efc 100644 --- a/1993/plummer/plummer.alt.c +++ b/1993/plummer/plummer.alt.c @@ -1 +1 @@ -char*_,*O;main(S,l)char**l;{*(O=*(l+++S-1)-1)=13,*l[1]=0;for(;;)for(printf(*l),_=O-1,usleep(Z);_>=*l&&++*_>(S+*O+S)*S;*_--=(S+*O)*S);} +char*_,*O;main(S,l)char**l;{if(S<3)exit(1);*(O=*(l+++S-1)-1)=13,*l[1]=0;for(;;)for(printf(*l),_=O-1,usleep(Z);_>=*l&&++*_>(S+*O+S)*S;*_--=(S+*O)*S);} diff --git a/1993/plummer/plummer.c b/1993/plummer/plummer.c index d0c61daa2..392b62bbb 100644 --- a/1993/plummer/plummer.c +++ b/1993/plummer/plummer.c @@ -1 +1 @@ -char*_,*O;main(S,l)char**l;{*(O=*(l+++S-1)-1)=13,*l[1]=0;for(;;)for(printf(*l),_=O-1;_>=*l&&++*_>(S+*O+S)*S;*_--=(S+*O)*S);} +char*_,*O;main(S,l)char**l;{if(S<3)exit(1);*(O=*(l+++S-1)-1)=13,*l[1]=0;for(;;)for(printf(*l),_=O-1;_>=*l&&++*_>(S+*O+S)*S;*_--=(S+*O)*S);} diff --git a/bugs.md b/bugs.md index 7df5d6f1e..4d3aae201 100644 --- a/bugs.md +++ b/bugs.md @@ -805,18 +805,6 @@ encourage you to test it. This should not be fixed. # 1993 -## 1993 plummber - -### STATUS: known bug - please help us fix -### Source code: [1993/plummer/plummer.c](1993/plummer/plummer.c) -### Information: [1993/plummer/README.md](1993/plummer/README.md) - -If not enough args are specified this program will likely crash or do something -else. - -If you want to try and fix this (mis)feature, you are welcome to try. - - ## 1993 lmfjyh ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 278636b9f..258969431 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1251,9 +1251,11 @@ this was made the alternate version, not the actual entry. ## [1993/plummer](1993/plummer/plummer.c) ([README.md](1993/plummer/README.md])) -Cody added an [alternate version](1993/plummer/plummer.alt.c) which uses -`usleep()` so you can see what is happening with faster systems. See the -README.md files for details. +Cody added check for two args. + +Cody also added an [alternate version](1993/plummer/plummer.alt.c) which uses +`usleep()` so you can see what is happening with faster systems. This version +also checks for two args. See the README.md files for details. ## [1993/rince](1993/rince/rince.c) ([README.md](1993/rince/README.md])) From e2a8f813dcbf194188bf3c78a6a84f12388e488a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:52:52 -0700 Subject: [PATCH 08/17] Fix both original and alt code for 1992/westley For both check args. For alt move main()'s code to new function as some versions of clang do not allow four args. Instead main() has two args now, the traditional argc and argv, and the other two are passed 0. --- 1992/westley/westley.alt.c | 3 ++- 1992/westley/westley.c | 6 +++--- bugs.md | 13 ------------- thanks-for-fixes.md | 15 +++++++++------ 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/1992/westley/westley.alt.c b/1992/westley/westley.alt.c index f188c7e1c..315dac7f0 100644 --- a/1992/westley/westley.alt.c +++ b/1992/westley/westley.alt.c @@ -1,4 +1,5 @@ -main(l,a,n,d)char**a,**n,**d;{int N=n,D=d;for(D=atoi(a[1])/2*80-atoi(a[2])-2043; +pain(l,a,n,d)char**a,**n,**d;{int N=n,D=d;for(D=atoi(a[1])/2*80-atoi(a[2])-2043; N="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd" [l++-3];)for(;N-->64;)putchar(!D+++33^l&1);} +main(l,a)char**a;{pain(l,a,0,0);} diff --git a/1992/westley/westley.c b/1992/westley/westley.c index d9a352b4c..f669a8457 100644 --- a/1992/westley/westley.c +++ b/1992/westley/westley.c @@ -1,7 +1,7 @@ main(l - ,a)char**a;{int n;int - d;for(d=atoi(a[1])/10*80- - atoi(a[2])/5-596;n="@NKA\ + ,a)char**a;{int n;int d; +if (l>2)for(d=atoi(a[1])/10 +*80-atoi(a[2])/5-596;n="@NKA\ CLCCGZAAQBEAADAFaISADJABBA^\ SNLGAQABDAXIMBAACTBATAHDBAN\ ZcEMMCCCCAAhEIJFAEAAABAfHJE\ diff --git a/bugs.md b/bugs.md index 4d3aae201..9fa12f326 100644 --- a/bugs.md +++ b/bugs.md @@ -788,19 +788,6 @@ As you might see the part under the `warning:` line is different. Can you help us? -## 1992 westley - -### STATUS: INABIAF - please **DO NOT** fix -### Source code: [1992/westley/westley.c](1992/westley/westley.c) -### Information: [1992/westley/README.md](1992/westley/README.md) - -This program and the alternate version will very likely crash or -[nuke](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire -world](https://en.wikipedia.org/wiki/Earth) or just the -[USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough -args. And not that we need any help with this or anything :-) but we do -encourage you to test it. This should not be fixed. - # 1993 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 258969431..d34d71cb5 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1209,15 +1209,18 @@ Cody fixed this to work for clang by changing the third and fourth arg of **` and some versions do not even allow a fourth arg. He also added the alternate version that the author gave in the remarks that is -specifically for the USA rather than the world. +specifically for the USA rather than the world. This had to be fixed for clang +as well to make the args of `main()` be the correct type and by moving the body +of main() to another function, `pain()`, which does the work since not all +versions of clang support four args to `main()`. -NOTE: as noted in the README.md file and the [bugs.md](/bugs.md), this program and the -[alternate version](1992/westley/westley.alt.c) will very likely crash or -[nuke](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire +Cody also added an arg check because the program and the +[alternate version](1992/westley/westley.alt.c) might have crashed or +[nuked](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire world](https://en.wikipedia.org/wiki/Earth) or just the [USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough -args (2). And not that we need the help or anything for this :-) but we do -encourage you to test this :-) This should NOT be fixed. +args (2). And not that we need the help or anything for this :-) but we +encourage you to try the original :-) ## [1993/jonth](1993/jonth/jonth.c) ([README.md](1993/jonth/README.md])) From dcd0b102afa65b4f835cf87fed4f59c756936f08 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:01:30 -0700 Subject: [PATCH 09/17] Add expected output of 1992/lush to bugs.md --- bugs.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bugs.md b/bugs.md index 9fa12f326..5beb23a03 100644 --- a/bugs.md +++ b/bugs.md @@ -785,6 +785,12 @@ lush.c:40:9: note: previous definition is here As you might see the part under the `warning:` line is different. +The entry is supposed to show warnings and then print: + +``` +Hello World. +``` + Can you help us? From 102675d4dd8ac55588715a0bebf88ba5dbd37da0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:34:57 -0700 Subject: [PATCH 10/17] Fix 1992/buzzard.1 - arg check --- 1992/buzzard.1/README.md | 14 -------------- 1992/buzzard.1/buzzard.1.c | 2 +- bugs.md | 10 ---------- thanks-for-fixes.md | 4 ++++ 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/1992/buzzard.1/README.md b/1992/buzzard.1/README.md index 8abd65c2b..5f8ae55d2 100644 --- a/1992/buzzard.1/README.md +++ b/1992/buzzard.1/README.md @@ -1,9 +1,6 @@ # Most Obfuscated Algorithm Sean Barrett\ -Software Construction Company\ -430 Southwest Parkway, #1906\ -College Station, TX 77840\ US @@ -14,17 +11,6 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [1992 buzzard.1 in bugs.md](/bugs.md#1992-buzzard.1). - - ## To use: ```sh diff --git a/1992/buzzard.1/buzzard.1.c b/1992/buzzard.1/buzzard.1.c index 9dfcbf146..bdf9574a6 100644 --- a/1992/buzzard.1/buzzard.1.c +++ b/1992/buzzard.1/buzzard.1.c @@ -1,7 +1,7 @@ #define A(c,a,b) t=b;t+=a;_(c) #define B(b,a) P(u,a)t=0;t-=a;R t+=u;t+=1;t/=2;_(b) #define b(x) x(g) -#define C ;main(argc,argv)char**argv;{for(;!w;){q=0;l +#define C ;main(argc,argv)char**argv;{if(argc<3)exit(1);for(;!w;){q=0;l #define c(y) x #define D(c,a,b) t=a;t/=b;_(c) #define d(x) S(x,x,1) diff --git a/bugs.md b/bugs.md index 5beb23a03..e06a9c44b 100644 --- a/bugs.md +++ b/bugs.md @@ -688,16 +688,6 @@ possibility. Can you find out how? # 1992 -## 1992 buzzard.1 - -### STATUS: known bug - please help us fix -### Source code: [1992/buzzard.1/buzzard.1.c](1992/buzzard.1/buzzard.1.c) -### Information: [1992/buzzard.1/README.md](1992/buzzard.1/README.md) - -This entry will crash without enough args (2). - -If you want to try and fix this (mis)feature, you are welcome to try. - ## 1992 kivinen diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index d34d71cb5..7be29ddfd 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1131,6 +1131,10 @@ one must keep the `Y[strlen(Y)-1]='\0';` part and keep it there. This is a complex change due to the way the program and Makefile generate additional tools. +## [1992/buzzard.1](1992/buzzard.1/buzzard.1.c) ([README.md](1992/buzzard.1/README.md)) + +Cody added a check for the right number of args, exiting 1 if not enough (2) +used. ## [1992/gson](1992/gson/gson.c) ([README.md](1992/gson/README.md])) From 6ac877dba961af8a00b49e8f72d9224f662830a7 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:37:01 -0700 Subject: [PATCH 11/17] Format fix + unrot13 text in 1992/gson/README.md --- 1992/gson/README.md | 271 ++++++++++++++++++++++---------------------- 1 file changed, 136 insertions(+), 135 deletions(-) diff --git a/1992/gson/README.md b/1992/gson/README.md index f0445fcc7..571a9ad66 100644 --- a/1992/gson/README.md +++ b/1992/gson/README.md @@ -1,9 +1,6 @@ # Most Humorous Output Andreas Gustafsson\ -Helsinki University of Technology\ -Arentikuja 1 D 305\ -00410 Helsinki\ Finland @@ -69,16 +66,16 @@ The name of the game: AG is short for either Anagram Generator or simply AnaGram. It might also be construed to mean Alphabet Game, and by pure coincidence it happens to be the author's initials. -\ -\ + + ### What it does -\ + AG takes one or more words as arguments, and tries to find anagrams of those words, i.e. words or sentences containing exactly the same letters. ### How to use it -\ + To run AG, you need a dictionary file consisting of distinct words in the natural language of your choice, one word on each line. If your machine doesn't have one already, you can make your own dictionary by concatenating a few @@ -102,7 +99,7 @@ limit can be changed using a numeric command line option, as in `./ag -4 international obfuscated c code contest Date: Mon, 30 Oct 2023 06:39:02 -0700 Subject: [PATCH 12/17] Update 1991/westley in bugs.md Added to the INABIAF that not only is there a way to cheat which was documented at the time and which I discovered when fixing the code but there is actually a way that I discovered recently where you can cheat but it still actually wins! Does that mean it is cheating as well? :-) Or is it that one cannot actually cheat a cheater? :-) Either way this felt like a good thing to add to the bugs.md as well. --- bugs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bugs.md b/bugs.md index e06a9c44b..3300f0f8a 100644 --- a/bugs.md +++ b/bugs.md @@ -682,8 +682,8 @@ someone called Cody's late grandmother said to him: 'it's not cheating unless you're caught'. :-) Please don't try and fix it as it's not a bug and was actually documented as a -possibility. Can you find out how? - +possibility. Can you find out how? There's also a way to make it so that even +when you're cheating it ends up winning! Can you figure that out as well? # 1992 From 92cb3c43dbb9d00d9ffb8a4d4bcb2a5da787f2f6 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:50:02 -0700 Subject: [PATCH 13/17] Reinstate NULL FILE * checks in 1991/dds --- 1991/dds/dds.c | 10 +++++----- bugs.md | 21 +++++++-------------- thanks-for-fixes.md | 10 ++++++---- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/1991/dds/dds.c b/1991/dds/dds.c index f9e5dce46..f05407a6e 100644 --- a/1991/dds/dds.c +++ b/1991/dds/dds.c @@ -11,8 +11,8 @@ aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ P1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssps!.Xop.sfu\ vso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d";int k;char R[4][99] ;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v -[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF -&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-69);}*r=0 -B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0' -)(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G':k= *p;G:p=s;while( -*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} +[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M': +Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return +system(q-69);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p-- +B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G' +:k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} diff --git a/bugs.md b/bugs.md index 3300f0f8a..bc5ab5a68 100644 --- a/bugs.md +++ b/bugs.md @@ -652,23 +652,16 @@ If you want to try and fix this (mis)feature, you are welcome to try. ## 1991 dds -### STATUS: INABIAF - please **DO NOT** fix +### STATUS: uses gets() - change to fgets() if possible ### Source code: [1991/dds/dds.c](1991/dds/dds.c) ### Information: [1991/dds/README.md](1991/dds/README.md) -If the BASIC file cannot be opened for reading or the output file cannot be -opened for writing the program will very likely crash or do something funny. -This is not a bug but a feature. Please do not fix this except for the -challenge to yourself. - -### STATUS: uses gets() - change to fgets() if possible - -That being said the compiled code uses `gets()` not `fgets()`. Can you fix this? -It's quite complicated to do: the `s` array is certainly relevant and you can -see a bit of the magic in the [thanks](/thanks-for-fixes.md) and the README.md -file for how it works. It's easy enough to get the code to refer to `fgets()` -and call it correctly but it might take more work to get the generated code -sorted. This will be looked at later. +The compiled code uses `gets()` not `fgets()`. Can you fix this? It's quite +complicated to do: the `s` array is certainly relevant and you can see a bit of +the magic in the [thanks](/thanks-for-fixes.md) and the README.md file for how +it works. It's easy enough to get the code to refer to `fgets()` and call it +correctly but it might take more work to get the generated code sorted. This +will be looked at later. ## 1991 westley diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 7be29ddfd..3234db882 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1032,10 +1032,12 @@ slightly more like the original, even though it's unused. ## [1991/dds](1991/dds/dds.c) ([README.md](1991/dds/README.md])) Cody fixed a segfault that prevented this entry from working in any condition -and he also made it work for clang. Clang (at least in some systems?) defaults -to having `-Werror` and the code that the entry generates had some warnings -that were causing compilation to fail as it just ran `cc a.c`. It ran it by what -was once `system(q-6);` but with clang this was not enough.. +and he also made it work for clang. He also added checks for NULL `FILE *`s. + +Clang (at least in some systems?) defaults to having `-Werror` and the code that +the entry generates had some warnings that were causing compilation to fail as +it just ran `cc a.c`. It ran it by what was once `system(q-6);` but with clang +this was not enough. The following had to be added to the string `s` (which to fix the segfault was changed from `char*s` to `char s[]`): From 1df3b50b23e3d1c612124f82d1fed4ed510cd209 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 06:57:21 -0700 Subject: [PATCH 14/17] Fix bugs in 1990/westley If no arg is specified it crashed. If arg was not a number > 0 it entered an infinite loop. Both have been fixed, exiting 1. These checks were NOT done in the alt code as that's a copy of the original code. --- 1990/westley/README.md | 21 ++------------------- 1990/westley/westley.c | 1 + bugs.md | 13 ------------- thanks-for-fixes.md | 5 +++++ 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/1990/westley/README.md b/1990/westley/README.md index c783b3654..fa3733e6b 100644 --- a/1990/westley/README.md +++ b/1990/westley/README.md @@ -15,30 +15,13 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: known bug - please help us fix -``` - -For more detailed information see [1990 westley in bugs.md](/bugs.md#1990-westley). - - ## To use: ```sh -./westley number +./westley 0. - +The number should be greater than 0. ## Try: diff --git a/1990/westley/westley.c b/1990/westley/westley.c index 70f787618..5362c1eb8 100644 --- a/1990/westley/westley.c +++ b/1990/westley/westley.c @@ -11,6 +11,7 @@ char*lie; dear; (char)lotte--; + if (ly < 2 || atoi(die[1])<1) exit(1); for(get= !me;; not){ 1 - out & out ;lie;{ diff --git a/bugs.md b/bugs.md index bc5ab5a68..487c9a485 100644 --- a/bugs.md +++ b/bugs.md @@ -634,19 +634,6 @@ will enter an infinite loop, printing 0 over and over again; another condition where this occurred was fixed but this one should not be fixed. Thank you. -## 1990 westley - -### STATUS: known bug - please help us fix -### Source code: [1990/westley/westley.c](1990/westley/westley.c) -### Information: [1990/westley/README.md](1990/westley/README.md) - -This entry will very likely crash or do something strange without an arg. - -This entry will also enter an infinite loop if input is not a number > 0. - -If you want to try and fix this (mis)feature, you are welcome to try. - - # 1991 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 3234db882..75dc48cd4 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1015,6 +1015,11 @@ was changed to just `1`. Since it's instructional to see the differences he has provided an alternate version, [westley.alt.c](1990/westley/westley.alt.c), which is the original code. +He also fixed the code to not enter an infinite loop if arg is a number not > 0 +and to not crash if no arg is specified. + +The alt code did NOT have arg checks added as it is actually a copy of the +original code. ## [1991/brnstnd](1991/brnstnd/brnstnd.c) ([README.md](1991/brnstnd/README.md])) From 1d6ef234d0d3fad9475d93dbade560d331428863 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:50:37 -0700 Subject: [PATCH 15/17] Fixes in 1990/jaw The program (and the generated program made by shark.sh) no longer use perror(3) and instead use fprintf(3) (writing to stderr). This is mostly because in macOS errno == 0 looks like an error. Some updates to the shark.sh script were also made. The bug status has been updated as there is apparently another bug though I was sure it was solved when I last looked at it. It happens with and without the above updates. I'm unsure about other things too but these are not in the bugs.md yet as I'm not even sure what to say just yet. Added try.sh script which does some of the commands. However as there is that bug it doesn't do any comparisons - for now. --- 1990/jaw/Makefile | 2 +- 1990/jaw/README.md | 8 ++++---- 1990/jaw/jaw.c | 2 +- 1990/jaw/shark.sh | 8 ++++---- 1990/jaw/try.sh | 11 +++++++++++ bugs.md | 45 +++++---------------------------------------- thanks-for-fixes.md | 12 +++++++++--- 7 files changed, 35 insertions(+), 53 deletions(-) create mode 100755 1990/jaw/try.sh diff --git a/1990/jaw/Makefile b/1990/jaw/Makefile index ee5a5042c..ae9b0c149 100644 --- a/1990/jaw/Makefile +++ b/1990/jaw/Makefile @@ -67,7 +67,7 @@ CINCLUDE= # Optimization # -OPT= -O3 +OPT= # Default flags for ANSI C compilation # diff --git a/1990/jaw/README.md b/1990/jaw/README.md index 0f3590854..89f0192df 100644 --- a/1990/jaw/README.md +++ b/1990/jaw/README.md @@ -67,7 +67,7 @@ shark.sh, contains a 'jaw.c' embedded within it! The sender must have `compress` and `btoa`. To send, try: ```sh -sh shark.sh jaw.* README.md > receive +./shark.sh jaw.* README.md > receive ``` The resulting file, `receive`, unpacks the input files @@ -86,7 +86,7 @@ cmp ../README.md README.md ### ABSTRACT #### Minimal, Universal File Bundling (or, Functional Obfuscation in a Self-Decoding Unix Shell Archive) -\ + James A. Woods\ Universities Space Research Association\ NASA Ames Research Center @@ -94,7 +94,7 @@ NASA Ames Research Center --- > "Use an algorithm, go to jail." ->\ +> > -- anon., circa 1988, pre-Morris worm era ---- @@ -134,7 +134,7 @@ environment. > And he shows them pearly white > Just a jackknife has Macheath, dear-- > And he keeps it out of sight. ->\ +> > -- Bertolt Brecht, Threepenny Opera ---------------------------------------------- diff --git a/1990/jaw/jaw.c b/1990/jaw/jaw.c index 6ab37e147..6bc92e1c4 100644 --- a/1990/jaw/jaw.c +++ b/1990/jaw/jaw.c @@ -1,5 +1,5 @@ #define C char -#define F X,perror("oops"),1 +#define F X,fprintf(stderr,"oops\n"),1 #define G getchar() #define I ;if( #define P putchar diff --git a/1990/jaw/shark.sh b/1990/jaw/shark.sh index 72190b1c3..bd0e8b675 100755 --- a/1990/jaw/shark.sh +++ b/1990/jaw/shark.sh @@ -11,16 +11,16 @@ for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done # PATH=$PATH:. a=atob m=unshark z=zcat r="rm -f $a $m* $z" v="cc -Wno-implicit-function-declaration -o $z $m.c" -trap "$r;exit 1" 1 2 13 15 +trap '$r;exit 1' 1 2 13 15 echo decoding... -(:|compress|./btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & / +(:|compress|./btoa|./$a|./$z)2>$m>&2||(sed '1,9s/./#define & / s/@/[w]/g s/C/char /g s/I/;if(/g s/W/;while(/g s/Y/%lx /g s/}/;}/g'>$m.c<<_&& -FX,perror("$m bite: resend"),1; +FX,fprintf(stderr,"$m bite: resend\n"),1; GgetC() H(w=g()) K[69001] @@ -43,5 +43,5 @@ Z,h@=w;n=8;f=Q+e;i=o=HIo<0)X,1;P(i)WH+1){Iw==Q&e){Z;m=n=8;f=QIH<0)X} c=wIw>=f)U++=i,w=oWw>=Q)U++=h@,w=t@;P(i=h@)Wp>D+Q)P(*--p) I(w=f)<1l<$m-&&$z<$m->$m&&tar xvf $m&&$r +($v)&&ln -f $z $a)&&./$a<<\w>./$m-&&./$z<./$m->./$m&&tar xvf ./$m&&$r Z diff --git a/1990/jaw/try.sh b/1990/jaw/try.sh new file mode 100755 index 000000000..a4c337b57 --- /dev/null +++ b/1990/jaw/try.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +echo "Running shark.sh:" +sh shark.sh README.md jaw.c README.md > receive || exit 1 +echo "Done." + +echo "Attempting to extract files:" + +mkdir -p test +cd test +sh ../receive diff --git a/bugs.md b/bugs.md index 487c9a485..39ac43dfe 100644 --- a/bugs.md +++ b/bugs.md @@ -579,46 +579,11 @@ You are welcome to try and fix it if you can! ### Source code: [1990/jaw/jaw.c](1990/jaw/jaw.c) ### Information: [1990/jaw/README.md](1990/jaw/README.md) -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the scripts to -work in modern systems. He notes however that the command in the try section, -the one to test the official C entry, **appears** (the keyword!) to not work -with macOS, giving: - - -```sh -$ echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw -oops: Undefined error: 0 -oops: Undefined error: 0 -``` - -However this is because the entry uses `perror()` and it just so happens that -the default `errno` of 0 gives that result. For instance if you run the -following C program under macOS you will get undefined error but if you do it -under Linux you'll likely get success. - - -```c -#include -#include -#include -int main() -{ - errno = 0; - printf("%d, %s\n", errno, strerror(errno)); -} -``` - -In fact the condition which is in the `a()` function on line 18 of the entry -namely: - - I k>16) - -is true on both linux and macOS, with `k` being equal to 22! - -Should the entry use `perror()`? Perhaps not but we're not sure of its purpose -so it should stay with this note. - -If you want to try and fix this (mis)feature, you are welcome to try. +It seems like the scripts do not work correctly, where not all files are +extracted. Some work was done to get them to work some but it does not appear +that all files can be extracted. For instance in the [try.sh](1990/jaw/try.sh) +script which Cody added it is supposed to add the README.md file to the archive +and it did at one point (or so he recalls) but now it doesn't seem to happen. ## 1990 theorem diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 75dc48cd4..6a3fbed22 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -933,9 +933,15 @@ With these improvements the entry looks much more like the original! ## [1990/jaw](1990/jaw/jaw.c) ([README.md](1990/jaw/README.md])) Cody fixed the script to work properly in modern environments (to do with `$PATH` -not having `.` in it). He notes that with an invocation in the try section will -with macOS show what appears to be an error message but is actually okay. He -gives more information in the [bugs.md](/bugs.md) file. +not having `.` in it). Other adjustments were made as well. + +He also changed the `perror(3)` call to `fprintf(3)` because in macOS when errno +is 0 it shows what looks like an error. + +He added the [try.sh](1990/jaw/try.sh) to run the commands that we suggested at +the time. However, there is a known bug still, see [bugs.md](bugs.md) for +details. + NOTE: as `btoa` is not common we used a ruby script from Yusuke. From ee02eaae4a4b5647db551e0a17cccfffb646c206 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:52:34 -0700 Subject: [PATCH 16/17] Make 1991/dds C generated code use fgets() This took less time than the previous fix (to let it work with clang) because after stupidly doing the decryption/encryption manually I had decided to write a simple program that does it instead. Now systems won't whine about gets() being unsafe. The thanks file further documents how this was done and the bugs.md file no longer has this entry. --- 1991/dds/README.md | 11 --------- 1991/dds/dds.c | 19 ++++++++------- bugs.md | 12 ---------- thanks-for-fixes.md | 57 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/1991/dds/README.md b/1991/dds/README.md index 311e8ba5f..78c7623aa 100644 --- a/1991/dds/README.md +++ b/1991/dds/README.md @@ -13,17 +13,6 @@ make all ``` -### Bugs and (Mis)features - -The current status of this entry is: - -``` -STATUS: INABIAF - please **DO NOT** fix -STATUS: uses gets() - change to fgets() if possible -``` - -For more detailed information see [1991 dds in bugs.md](/bugs.md#1991-dds). - ## To use: diff --git a/1991/dds/dds.c b/1991/dds/dds.c index f05407a6e..b313abf71 100644 --- a/1991/dds/dds.c +++ b/1991/dds/dds.c @@ -7,12 +7,13 @@ o)*|gps)<<*txjudi)m*|aQdbtf!::::;sfuvsom,2aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ R%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\ \\(aP3Q(^*m>g\\(aP3Q(^::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ -P1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssps!.Xop.sfu\ -vso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d";int k;char R[4][99] -;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v -[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M': -Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return -system(q-69);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p-- -B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G' -:k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} +aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)ghfut)c-::-tuejo**aHb%JD12JON1!Qjg)a%LN1U\ +P1D12JIQUaP1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssp\ +s!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!.jodmvef!tuejp/i!b/d"; +int k;char R[4][99];main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(* +q)--;{FILE*i=fopen(v[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p +++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n" +,o);fclose(o);return system(q-86);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O': +Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p; +if(**R==k)goto G B'G':k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0' +][0]++;}}} diff --git a/bugs.md b/bugs.md index 39ac43dfe..d83c01ed7 100644 --- a/bugs.md +++ b/bugs.md @@ -604,18 +604,6 @@ where this occurred was fixed but this one should not be fixed. Thank you. ## 1991 dds -### STATUS: uses gets() - change to fgets() if possible -### Source code: [1991/dds/dds.c](1991/dds/dds.c) -### Information: [1991/dds/README.md](1991/dds/README.md) - -The compiled code uses `gets()` not `fgets()`. Can you fix this? It's quite -complicated to do: the `s` array is certainly relevant and you can see a bit of -the magic in the [thanks](/thanks-for-fixes.md) and the README.md file for how -it works. It's easy enough to get the code to refer to `fgets()` and call it -correctly but it might take more work to get the generated code sorted. This -will be looked at later. - - ## 1991 westley ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 6a3fbed22..814fbedbb 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1044,12 +1044,17 @@ slightly more like the original, even though it's unused. Cody fixed a segfault that prevented this entry from working in any condition and he also made it work for clang. He also added checks for NULL `FILE *`s. +Furthermore he changed it so that the C from the BASIC uses `fgets()`, not +`gets()`. For the magic of clang and `fgets()` see below. Clang (at least in some systems?) defaults to having `-Werror` and the code that the entry generates had some warnings that were causing compilation to fail as it just ran `cc a.c`. It ran it by what was once `system(q-6);` but with clang this was not enough. +(Cody stupidly did the below manually until he thought to write a simple program +to do the conversions which he used for `gets()` to `fgets()`.) + The following had to be added to the string `s` (which to fix the segfault was changed from `char*s` to `char s[]`): @@ -1076,10 +1081,58 @@ string. Thus the end of the string actually looks like: !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d ``` -With these changes in place it will compile and work with both gcc and clang. +But then there is the matter of getting the C to use `fgets()`. As can be seen +above it's not as simple as changing `gets()` to `fgets()`. This was more magic +characters that had to be updated and some added. The C code: + +```c +atoi(gets(b)) +``` + +is in the string: + +``` +bupj)hfut)c** +``` + +which was changed to be (in C): + +```c +atoi(fgets(b,99,stdin)) +``` + +which in the program is: + +``` +bupj)ghfut)c-::-tuejo** +``` + +That's fine and well but since the code does not include `stdio.h` there +obviously would be a compilation error. Thus the compiler line had to updated to +have `-include stdio.h` which in this rotated string is: + +``` +.jodmvef!tuejp/i +``` + +which had to be added after: + +``` +efdmbsbujpo! +``` + +which is the end of the warning disabled for clang as described above. + +But now the `system(q-69);` had to be changed to `system(q-86);`. + +With these changes in place it will compile and work with both gcc and clang and +the C code generated will use `fgets()`, not `gets()`, therefore removing the +annoying warnings. Note that the array passed to `fgets()` is an int but that +was the same for `gets()` and is not necessary to update to a `char[]`. + The key to the string is that it rotates the character by `+1`. This was not immediately clear until reading the author's remarks so there was an alt version -that was something of a kludge, running `make a` instead. +that was something of a kludge, running `make a` instead but that was removed. Cody also fixed a typo in LANDER.BAS. From 44efc33d5ab9dc22a13590737b7e595cb806271a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:22:31 -0700 Subject: [PATCH 17/17] Add tip for 1989/westley ver2 bug to bugs.md --- bugs.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bugs.md b/bugs.md index d83c01ed7..a8f02e767 100644 --- a/bugs.md +++ b/bugs.md @@ -566,9 +566,24 @@ It should be noted that in additional to rot13 names there is code that is the reverse of other code (also wrt names). See the source file and the README.md (in the author's remarks) for more details. -Fixing the (Mis)feature is likely to be a difficult challenge. -You are welcome to try and fix it if you can! +Fixing the (Mis)feature is likely to be a very difficult challenge. You are +welcome to try and fix it if you can! +### A tip from Cody: + +The reason this is crashing is that the array `irk` is being accessed way out of +bounds by the int `gnat`. For instance: + +``` +Program terminated with signal SIGSEGV, Segmentation fault. +#0 0x0000000000401335 in main (ABBA@entry=, tang@entry=, gnat@entry=, Near@entry=) + at ver2.c:23 +23 &&gnat!({)Near,noon,/*krelc*/)<0&&(Near= - irk[-gnat--]-2)))&&main(ABBA, +(gdb) p gnat +$1 = -518733305 +``` + +The real trouble is that the code is generated and in a complex way. # 1990