Hi,

Decoding using the -lf option on powerpc made ish freeze. A looped
fgetc(3) call never reached EOF, since the return value was stored
as a char, that is unsigned on powerpc and arm*, instead of int.

--8<--
$ cd /tmp && cp /bin/ls .
$ ish -ss ls
$ rm ls
$ ish -lf ls.ish
[...]
< Restore from ls.ish >
<<< ls for UNIX ( use shift_jis ) 2021/07/24 11:55:40 357460 byte >>>
ls :  Error!! File delete.
<<< ls for UNIX ( use shift_jis ) 2021/07/24 11:55:40 357460 byte >>>
ls :
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Finished.
[infinite loop]
-->8--

With the below diff, ish properly quits once the decoding has been
done, and the decoded ls works. Tested on amd64 and macppc.

OK?

Charlène.


Index: Makefile
===================================================================
RCS file: /cvs/ports/converters/ish/Makefile,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 Makefile
--- Makefile    14 Jul 2019 02:16:51 -0000      1.24
+++ Makefile    24 Jul 2021 08:31:46 -0000
@@ -4,6 +4,7 @@ COMMENT=        binary-to-text file converter
 
 DISTNAME=      ish201a5
 PKGNAME=       ish-2.01a5
+REVISION=      0
 CATEGORIES=    converters
 
 PERMIT_PACKAGE=                no license
Index: patches/patch-decode_c
===================================================================
RCS file: /cvs/ports/converters/ish/patches/patch-decode_c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 patch-decode_c
--- patches/patch-decode_c      30 Dec 2011 23:14:34 -0000      1.1
+++ patches/patch-decode_c      24 Jul 2021 08:31:46 -0000
@@ -1,9 +1,11 @@
 $OpenBSD: patch-decode_c,v 1.1 2011/12/30 23:14:34 sthen Exp $
 
-Fix: When decoding, the status display has Y2K problem.
+Hunk #1: When decoding, the status display has Y2K problem.
+Hunk #2: fix an infinite loop on unsigned char archs (powerpc and arm*)
 
---- decode.c.orig      Sun Jan  7 10:46:37 1996
-+++ decode.c   Fri Dec 30 23:09:44 2011
+Index: decode.c
+--- decode.c.orig
++++ decode.c
 @@ -273,8 +273,8 @@ ish_head *head;
        tm.tm_min = (p[1]&0x07)<<3;
        tm.tm_min += p[0]>>5;
@@ -15,3 +17,13 @@ Fix: When decoding, the status display h
  #ifdef __TURBOC__
        memcpy( &timep[0], head->time, 4);
        timep[1] = timep[0];
+@@ -675,8 +675,7 @@ FILE    *ipath;
+ int     maxlen;
+ char    *buff;
+ {
+-    int     i,j;
+-    char    c;
++    int     c,i,j;
+ 
+     if((decok & 0x80) == 0)
+         j=78;

Reply via email to