Sat Jan 8 14:43:09 2022 UTC ()
arj: fix pointer truncation issues, alignment issues and other LP64 issues

Mostly via Debian. Re-enable package on LP64.


(tnn)
diff -r1.35 -r1.36 pkgsrc/archivers/arj/Makefile
diff -r1.25 -r1.26 pkgsrc/archivers/arj/distinfo
diff -r0 -r1.1 pkgsrc/archivers/arj/patches/patch-arj__arcv.c
diff -r0 -r1.1 pkgsrc/archivers/arj/patches/patch-arj__proc.c
diff -r0 -r1.1 pkgsrc/archivers/arj/patches/patch-arj__proc.h
diff -r0 -r1.1 pkgsrc/archivers/arj/patches/patch-arjtypes.c
diff -r0 -r1.1 pkgsrc/archivers/arj/patches/patch-postproc.c
diff -r1.1 -r1.2 pkgsrc/archivers/arj/patches/patch-decode.c

cvs diff -r1.35 -r1.36 pkgsrc/archivers/arj/Makefile (expand / switch to unified diff)

--- pkgsrc/archivers/arj/Makefile 2020/01/26 05:26:08 1.35
+++ pkgsrc/archivers/arj/Makefile 2022/01/08 14:43:09 1.36
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.35 2020/01/26 05:26:08 rillig Exp $ 1# $NetBSD: Makefile,v 1.36 2022/01/08 14:43:09 tnn Exp $
2 2
3DISTNAME= arj-3.10.22 3DISTNAME= arj-3.10.22
4PKGREVISION= 2 4PKGREVISION= 3
5CATEGORIES= archivers 5CATEGORIES= archivers
6MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=arj/} 6MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=arj/}
7 7
8MAINTAINER= pkgsrc-users@NetBSD.org 8MAINTAINER= pkgsrc-users@NetBSD.org
9HOMEPAGE= http://arj.sourceforge.net/ 9HOMEPAGE= http://arj.sourceforge.net/
10COMMENT= Open-source ARJ archiver 10COMMENT= Open-source ARJ archiver
11LICENSE= gnu-gpl-v2 11LICENSE= gnu-gpl-v2
12 12
13MAKE_JOBS_SAFE= no 13MAKE_JOBS_SAFE= no
14 14
15USE_TOOLS+= autoconf gmake 15USE_TOOLS+= autoconf gmake
16GNU_CONFIGURE= yes 16GNU_CONFIGURE= yes
17CONFIGURE_ENV+= LD=${LD:Q} 17CONFIGURE_ENV+= LD=${LD:Q}
@@ -21,23 +21,21 @@ MAKE_FLAGS+= INSTALL_DIR=${INSTALL_PROG @@ -21,23 +21,21 @@ MAKE_FLAGS+= INSTALL_DIR=${INSTALL_PROG
21 21
22INSTALL_UNSTRIPPED= yes # $LOCALBASE/bin/arj must have symbol table 22INSTALL_UNSTRIPPED= yes # $LOCALBASE/bin/arj must have symbol table
23ARJ_DOCSDIR= ${PREFIX}/share/doc/arj 23ARJ_DOCSDIR= ${PREFIX}/share/doc/arj
24 24
25pre-configure: 25pre-configure:
26 ${CP} -f ${WRKSRC}/environ.c ${WRKSRC}/environ.c.1 26 ${CP} -f ${WRKSRC}/environ.c ${WRKSRC}/environ.c.1
27 ${SED} -e 's|@PREFIX@|${PREFIX}|g' < ${WRKSRC}/environ.c.1 \ 27 ${SED} -e 's|@PREFIX@|${PREFIX}|g' < ${WRKSRC}/environ.c.1 \
28 > ${WRKSRC}/environ.c 28 > ${WRKSRC}/environ.c
29 ${RM} -f ${WRKSRC}/environ.c.1 29 ${RM} -f ${WRKSRC}/environ.c.1
30 cd ${WRKSRC}/gnu && autoconf 30 cd ${WRKSRC}/gnu && autoconf
31 31
32INSTALLATION_DIRS+= ${ARJ_DOCSDIR} 32INSTALLATION_DIRS+= ${ARJ_DOCSDIR}
33 33
34BROKEN_ON_PLATFORM= ${LP64PLATFORMS} 
35 
36post-install: 34post-install:
37 ${INSTALL_DATA} ${WRKSRC}/doc/COPYING ${WRKSRC}/doc/debug.txt \ 35 ${INSTALL_DATA} ${WRKSRC}/doc/COPYING ${WRKSRC}/doc/debug.txt \
38 ${DESTDIR}${ARJ_DOCSDIR} 36 ${DESTDIR}${ARJ_DOCSDIR}
39.for i in arjl.txt arjs.txt history.txt readme.txt unix.txt 37.for i in arjl.txt arjs.txt history.txt readme.txt unix.txt
40 ${INSTALL_DATA} ${WRKSRC}/resource/en/${i:Q} ${DESTDIR}${ARJ_DOCSDIR} 38 ${INSTALL_DATA} ${WRKSRC}/resource/en/${i:Q} ${DESTDIR}${ARJ_DOCSDIR}
41.endfor 39.endfor
42 40
43.include "../../mk/bsd.pkg.mk" 41.include "../../mk/bsd.pkg.mk"

cvs diff -r1.25 -r1.26 pkgsrc/archivers/arj/distinfo (expand / switch to unified diff)

--- pkgsrc/archivers/arj/distinfo 2021/10/26 09:57:04 1.25
+++ pkgsrc/archivers/arj/distinfo 2022/01/08 14:43:09 1.26
@@ -1,21 +1,26 @@ @@ -1,21 +1,26 @@
1$NetBSD: distinfo,v 1.25 2021/10/26 09:57:04 nia Exp $ 1$NetBSD: distinfo,v 1.26 2022/01/08 14:43:09 tnn Exp $
2 2
3BLAKE2s (arj-3.10.22.tar.gz) = 3693d1767527e7f1cdc813d838728389c4ec6fb7910ed272eb1aa1d9645f77eb 3BLAKE2s (arj-3.10.22.tar.gz) = 3693d1767527e7f1cdc813d838728389c4ec6fb7910ed272eb1aa1d9645f77eb
4SHA512 (arj-3.10.22.tar.gz) = 4730dfdbab4f8095396c337578ed69bdaae52955ad468db50b52af8ad2846ecd6cfc05eb3ac0d03838c1c32ea60126f14a22b93e8181c06b9546456f3937ff76 4SHA512 (arj-3.10.22.tar.gz) = 4730dfdbab4f8095396c337578ed69bdaae52955ad468db50b52af8ad2846ecd6cfc05eb3ac0d03838c1c32ea60126f14a22b93e8181c06b9546456f3937ff76
5Size (arj-3.10.22.tar.gz) = 431467 bytes 5Size (arj-3.10.22.tar.gz) = 431467 bytes
 6SHA1 (patch-arj__arcv.c) = 4d6c0df2a7845f71896dcd989ac3fc935b972ec7
 7SHA1 (patch-arj__proc.c) = 267a9837b0655b2534f2f25a76b1055bb802d9d6
 8SHA1 (patch-arj__proc.h) = 517d695638ac7c0ae319f5249dc955b3c3c77590
6SHA1 (patch-arj__user.c) = 011e5deaa24c696b212beadad7d386ccb3c7112d 9SHA1 (patch-arj__user.c) = 011e5deaa24c696b212beadad7d386ccb3c7112d
7SHA1 (patch-arjdata.c) = 4e4c142b97feee0673b14ea6f454f3d9de45f584 10SHA1 (patch-arjdata.c) = 4e4c142b97feee0673b14ea6f454f3d9de45f584
8SHA1 (patch-arjdisp.c) = d843d4dd1006ea30e8bb3a2acddbc2f0ac221abd 11SHA1 (patch-arjdisp.c) = d843d4dd1006ea30e8bb3a2acddbc2f0ac221abd
9SHA1 (patch-arjsfx.c) = c9e2314d0933cdc12f8e01ca16bc9222ac4e10b9 12SHA1 (patch-arjsfx.c) = c9e2314d0933cdc12f8e01ca16bc9222ac4e10b9
10SHA1 (patch-decode.c) = 15c31c3bf1303370691b701a98bad88ae1b0967b 13SHA1 (patch-arjtypes.c) = 3f4f83472fa70c55908fe6d89fa0a3d009e68e8a
 14SHA1 (patch-decode.c) = d6a2a4f60cb326aabb6bd25973d0aa7901c8595f
11SHA1 (patch-environ.c) = e306005a88825b2bfd5b3bb35b18710d26a4c885 15SHA1 (patch-environ.c) = e306005a88825b2bfd5b3bb35b18710d26a4c885
12SHA1 (patch-exe__sear.c) = 6d8db5a2cdb8f2452b96cf4d09687ae9d45d3e17 16SHA1 (patch-exe__sear.c) = 6d8db5a2cdb8f2452b96cf4d09687ae9d45d3e17
13SHA1 (patch-fardata.c) = b76ac5a168b9a8e288a610dce093280d31520af6 17SHA1 (patch-fardata.c) = b76ac5a168b9a8e288a610dce093280d31520af6
14SHA1 (patch-gnu_config.h.in) = 2cf609a6c7cb4e32441a433db3dc9cc04c23ae2a 18SHA1 (patch-gnu_config.h.in) = 2cf609a6c7cb4e32441a433db3dc9cc04c23ae2a
15SHA1 (patch-gnu_configure.in) = 062f3dc1eee6f009dfdfa432bb3c138a9c28a829 19SHA1 (patch-gnu_configure.in) = 062f3dc1eee6f009dfdfa432bb3c138a9c28a829
16SHA1 (patch-gnu_makefile.in) = db8a0afa61f49242e9fd601d5fc3167cf75f748b 20SHA1 (patch-gnu_makefile.in) = db8a0afa61f49242e9fd601d5fc3167cf75f748b
17SHA1 (patch-integr.c) = fade32219b21ac3382028bf23ee4171d8d095b5f 21SHA1 (patch-integr.c) = fade32219b21ac3382028bf23ee4171d8d095b5f
18SHA1 (patch-msgbind.c) = fa395b0b8b74f4b430a870254a1aa1554f2bb8e7 22SHA1 (patch-msgbind.c) = fa395b0b8b74f4b430a870254a1aa1554f2bb8e7
 23SHA1 (patch-postproc.c) = c107de57a691a4937007eca5d0e4afdbc9fa0ba3
19SHA1 (patch-register.c) = 8d81e663b499a45f7faa52b16a6cee47394cd09c 24SHA1 (patch-register.c) = 8d81e663b499a45f7faa52b16a6cee47394cd09c
20SHA1 (patch-resource_resource.txt) = ea7044dc8a6e4fed213f00f8db9f6c1ab5df6f72 25SHA1 (patch-resource_resource.txt) = ea7044dc8a6e4fed213f00f8db9f6c1ab5df6f72
21SHA1 (patch-uxspec.c) = 24a22fa2822704e620b38df12b76ef88fe908863 26SHA1 (patch-uxspec.c) = 24a22fa2822704e620b38df12b76ef88fe908863

File Added: pkgsrc/archivers/arj/patches/patch-arj__arcv.c
$NetBSD: patch-arj__arcv.c,v 1.1 2022/01/08 14:43:09 tnn Exp $

debian/003_64_bit_clean.patch
Description: Make code 64-bit clean.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Bug-Debian: https://bugs.debian.org/339815
Forwarded: no
Last-Update: 2005-11-24

--- arj_arcv.c.orig	2005-06-21 19:53:12.000000000 +0000
+++ arj_arcv.c
@@ -59,27 +59,27 @@ static char idxid_fault[]="?";
 #define setup_hput(ptr) (tmp_hptr=(ptr))
 
 #define hget_byte() (*(tmp_hptr++)&0xFF)
-#define hput_byte(c) (*(tmp_hptr++)=(char) (c))
+#define hput_byte(c) (*(tmp_hptr++)=(uint8_t) (c))
 
 /* Reads two bytes from the header, incrementing the pointer */
 
-static unsigned int hget_word()
+static uint16_t hget_word()
 {
- unsigned int result;
+ uint16_t result;
 
  result=mget_word(tmp_hptr);
- tmp_hptr+=sizeof(short);
+ tmp_hptr+=sizeof(uint16_t);
  return result;
 }
 
 /* Reads four bytes from the header, incrementing the pointer */
 
-static unsigned long hget_longword()
+static uint32_t hget_longword()
 {
- unsigned long result;
+ uint32_t result;
 
  result=mget_dword(tmp_hptr);
- tmp_hptr+=sizeof(unsigned long);
+ tmp_hptr+=sizeof(uint32_t);
  return result;
 }
 
@@ -87,18 +87,18 @@ static unsigned long hget_longword()
 
 /* Writes two bytes to the header, incrementing the pointer */
 
-static void hput_word(unsigned int w)
+static void hput_word(uint16_t w)
 {
  mput_word(w,tmp_hptr); 
- tmp_hptr+=sizeof(unsigned short);
+ tmp_hptr+=sizeof(uint16_t);
 }
 
 /* Writes four bytes to the header, incrementing the pointer */
 
-static void hput_longword(unsigned long l)
+static void hput_longword(uint32_t l)
 {
  mput_dword(l,tmp_hptr);
- tmp_hptr+=sizeof(unsigned long);
+ tmp_hptr+=sizeof(uint32_t);
 }
 
 /* Calculates and stores the basic header size */

File Added: pkgsrc/archivers/arj/patches/patch-arj__proc.c
$NetBSD: patch-arj__proc.c,v 1.1 2022/01/08 14:43:09 tnn Exp $

debian/001_arches_align.patch
Description: Correct build failure on ia64 due to unaligned memory access.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Forwarded: no
Last-Update: 2008-06-16


debian/003_64_bit_clean.patch
Description: Make code 64-bit clean.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Bug-Debian: https://bugs.debian.org/339815
Forwarded: no
Last-Update: 2005-11-24

debian/self_integrity_64bit.patch
Description: Fix arj self-integrity check on 64-bit systems
Author: B Watson <yalhcru@gmail.com>
Origin: other, http://slackbuilds.org/cgit/slackbuilds/tree/system/arj/patches/SBo_integrity_64bit.patch
Forwarded: no
Reviewed-By: Guillem Jover <guillem@debian.org>
Last-Update: 2014-08-06

--- arj_proc.c.orig	2022-01-08 14:35:06.610901643 +0000
+++ arj_proc.c
@@ -586,7 +586,7 @@ int search_for_extension(char *name, cha
 /* Returns the exact amount of data that could be safely written to the
    destination volume */
 
-unsigned long get_volfree(unsigned int increment)
+unsigned long get_volfree(unsigned long increment)
 {
  unsigned long pvol;
  unsigned int arjsec_overhead;
@@ -606,7 +606,7 @@ unsigned long get_volfree(unsigned int i
  remain=volume_limit-ftell(aostream)-pvol-(long)arjsec_overhead-
         (long)out_bytes-(long)cpos-(long)ext_voldata-
         MULTIVOLUME_RESERVE-t_volume_offset;
- return((unsigned long)min(remain, (unsigned long)increment));
+ return((unsigned long)min(remain, increment));
 }
 
 /* Performs various checks when multivolume data is packed to predict an
@@ -2467,14 +2467,14 @@ static int get_str_from_jq()
     *tsptr='\0';
   endptr=tsptr;
   tsptr=sptr;
-  while((unsigned int)tsptr<(unsigned int)endptr&&patterns<SEARCH_STR_MAX)
+  while((intptr_t)tsptr<(intptr_t)endptr&&patterns<SEARCH_STR_MAX)
   {
    while(*tsptr=='\0')
     tsptr++;
-   if((unsigned int)tsptr<(unsigned int)endptr)
+   if((intptr_t)tsptr<(intptr_t)endptr)
    {
     search_str[patterns++]=tsptr;
-    while(*tsptr!='\0'&&(unsigned int)tsptr<(unsigned int)endptr)
+    while(*tsptr!='\0'&&(intptr_t)tsptr<(intptr_t)endptr)
      tsptr++;
    }
   }
@@ -2899,12 +2899,12 @@ char *ltrim(char *str)
 }
 #endif
 
-#if defined(WORDS_BIGENDIAN)&&!defined(ARJDISP)&&!defined(REGISTER)
+#if (defined(WORDS_BIGENDIAN) || defined(ALIGN_POINTERS)) && !defined(ARJDISP) && !defined(REGISTER)
 /* Model-independent routine to get 2 bytes from far RAM */
 
-unsigned int mget_word(char FAR *p)
+uint16_t mget_word(char FAR *p)
 {
- unsigned int b0, b1;
+ uint16_t b0, b1;
 
  b0=mget_byte(p);
  b1=mget_byte(p+1);
@@ -2913,9 +2913,9 @@ unsigned int mget_word(char FAR *p)
 
 /* Model-independent routine to get 4 bytes from far RAM */
 
-unsigned long mget_dword(char FAR *p)
+uint32_t mget_dword(char FAR *p)
 {
- unsigned long w0, w1;
+ uint32_t w0, w1;
 
  w0=mget_word(p);
  w1=mget_word(p+2);
@@ -2924,7 +2924,7 @@ unsigned long mget_dword(char FAR *p)
 
 /* Model-independent routine to store 2 bytes in far RAM */
 
-void mput_word(unsigned int w, char FAR *p)
+void mput_word(uint16_t w, char FAR *p)
 {
  mput_byte(w&0xFF, p);
  mput_byte(w>>8  , p+1);
@@ -2932,7 +2932,7 @@ void mput_word(unsigned int w, char FAR 
 
 /* Model-independent routine to store 4 bytes in far RAM */
 
-void mput_dword(unsigned long d, char FAR *p)
+void mput_dword(uint32_t d, char FAR *p)
 {
  mput_word(d&0xFFFF, p);
  mput_word(d>>16   , p+2);

File Added: pkgsrc/archivers/arj/patches/patch-arj__proc.h
$NetBSD: patch-arj__proc.h,v 1.1 2022/01/08 14:43:09 tnn Exp $

debian/001_arches_align.patch
Description: Correct build failure on ia64 due to unaligned memory access.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Forwarded: no
Last-Update: 2008-06-16


debian/003_64_bit_clean.patch
Description: Make code 64-bit clean.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Bug-Debian: https://bugs.debian.org/339815
Forwarded: no
Last-Update: 2005-11-24

--- arj_proc.h.orig	2022-01-08 14:35:15.711534423 +0000
+++ arj_proc.h
@@ -8,15 +8,17 @@
 #ifndef ARJ_PROC_INCLUDED
 #define ARJ_PROC_INCLUDED
 
+#include <stdint.h>
+
 /* Helper macros */
 
-#define mget_byte(p) (*(unsigned char FAR *)(p)&0xFF)
-#define mput_byte(c, p) *(unsigned char FAR *)(p)=(unsigned char)(c)
-#ifndef WORDS_BIGENDIAN
-#define mget_word(p) (*(unsigned short *)(p)&0xFFFF)
-#define mput_word(w,p) (*(unsigned short *)(p)=(unsigned short)(w))
-#define mget_dword(p) (*(unsigned long *)(p))
-#define mput_dword(w,p) (*(unsigned long *)(p)=(unsigned long)(w))
+#define mget_byte(p) (*(uint8_t FAR *)(p)&0xFF)
+#define mput_byte(c, p) *(uint8_t FAR *)(p)=(uint8_t)(c)
+#if !defined(ALIGN_POINTERS) && !defined(WORDS_BIGENDIAN)
+#define mget_word(p) (*(uint16_t *)(p)&0xFFFF)
+#define mput_word(w,p) (*(uint16_t *)(p)=(uint16_t)(w))
+#define mget_dword(p) (*(uint32_t *)(p))
+#define mput_dword(w,p) (*(uint32_t *)(p)=(uint32_t)(w))
 #endif
 
 /* Prototypes */
@@ -31,7 +33,7 @@ void copy_bytes(unsigned long nbytes);
 int translate_path(char *name);
 void restart_proc(char *dest);
 int search_for_extension(char *name, char *ext_list);
-unsigned long get_volfree(unsigned int increment);
+unsigned long get_volfree(unsigned long increment);
 unsigned int check_multivolume(unsigned int increment);
 void store();
 void hollow_encode();
@@ -60,11 +62,11 @@ void pack_mem(struct mempack *mempack);
 void unpack_mem(struct mempack *mempack);
 void strip_lf(char *str);
 char *ltrim(char *str);
-#ifdef WORDS_BIGENDIAN
-unsigned int mget_word(char FAR *p);
-unsigned long mget_dword(char FAR *p);
-void mput_word(unsigned int w, char FAR *p);
-void mput_dword(unsigned long d, char FAR *p);
+#if defined(ALIGN_POINTERS) || defined(WORDS_BIGENDIAN)
+uint16_t mget_word(char FAR *p);
+uint32_t mget_dword(char FAR *p);
+void mput_word(uint16_t w, char FAR *p);
+void mput_dword(uint32_t d, char FAR *p);
 #endif
 
 #endif

File Added: pkgsrc/archivers/arj/patches/patch-arjtypes.c
$NetBSD: patch-arjtypes.c,v 1.1 2022/01/08 14:43:09 tnn Exp $

Description: Use proper time_t type instead of unsigned long for variables
 that are being passed to localhost() and gmtime(). This fixes several
 segfaults on x32.
Author: Guillem Jover <guillem@debian.org>
Origin: vendor
Forwarded: no
Last-Update: 2019-08-11

--- arjtypes.c.orig	2005-06-23 10:00:54.000000000 +0000
+++ arjtypes.c
@@ -135,11 +135,11 @@ static int isleapyear(int year)
 
 /* Converts a UNIX timestamp to the DOS style */
 
-static unsigned long ts_unix2dos(const long ts)
+static unsigned long ts_unix2dos(time_t ts)
 {
  struct tm *stm;
 
- stm=arj_localtime((time_t*)&ts);
+ stm=arj_localtime(&ts);
  return(get_tstamp(stm->tm_year+1900, stm->tm_mon+1, stm->tm_mday,
         stm->tm_hour, stm->tm_min, stm->tm_sec));
 }
@@ -148,14 +148,14 @@ static unsigned long ts_unix2dos(const l
 
 static unsigned long mk_unixtime(int y, int m, int d, int hh, int mm, int ss)
 {
- unsigned long u=0, ts;
+ unsigned long u=0;
  unsigned int i, v;
  /* Clash with NetBSD/x86-64 patch: leaving rc as unsigned long still permits
     to escape the year 2038 problem in favor of year 2106 problem, while a
     dedicated time_t structure can be expected as a 64-bit value on relevant
     platforms -- ASR fix 25/01/2004 */
- unsigned long rc;
- time_t tt;
+ time_t rc;
+ time_t tt, ts;
  long tzshift, shiftd1, shiftd2;
  struct tm *stm;
 
@@ -191,7 +191,7 @@ static unsigned long mk_unixtime(int y, 
    u+=isleapyear(y);
  }
  rc=86400*(unsigned long)(u+d-1)+(unsigned long)hh*3600+(unsigned long)mm*60+(unsigned long)ss;
- stm=arj_localtime((const long *)&rc);
+ stm=arj_localtime(&rc);
  debug_assert(stm!=NULL);               /* LIBCS.DLL returns NULL for unixtime beyond
                                            0x7FFFFFFF */
  tzshift=(long)stm->tm_hour*3600+(long)stm->tm_min*60;
@@ -203,7 +203,7 @@ static unsigned long mk_unixtime(int y, 
   debug_assert(stm!=NULL);
   stm->tm_year+=v;
  #else
-  stm=gmtime((const long *)&ts);  
+  stm=gmtime(&ts);
  #endif
  shiftd2=stm->tm_mday;
  /* Local time overruns GMT, add 24 hours for safety */
@@ -304,8 +304,9 @@ void make_timestamp(struct timestamp *de
 void timestamp_to_str(char *str, struct timestamp *ts)
 {
  struct tm *stm;
+ time_t ut = ts->unixtime;
 
- stm=arj_localtime((time_t *)&ts->unixtime);
+ stm=arj_localtime(&ut);
  /* Workaround for a MS C v 7.0 CRT bug */
  #if TARGET==DOS&&COMPILER==MSC&&_MSC_VER==700
   if(stm->tm_year<70)                   /* 31 -> 101 */

File Added: pkgsrc/archivers/arj/patches/patch-postproc.c
$NetBSD: patch-postproc.c,v 1.1 2022/01/08 14:43:09 tnn Exp $

debian/self_integrity_64bit.patch
Description: Fix arj self-integrity check on 64-bit systems
Author: B Watson <yalhcru@gmail.com>
Origin: other, http://slackbuilds.org/cgit/slackbuilds/tree/system/arj/patches/SBo_integrity_64bit.patch
Forwarded: no
Reviewed-By: Guillem Jover <guillem@debian.org>
Last-Update: 2014-08-06

--- postproc.c.orig	2003-06-22 11:12:28.000000000 +0000
+++ postproc.c
@@ -6,6 +6,7 @@
  *
  */
 
+#include <stdint.h>
 #include "arj.h"
 
 /* Operations */
@@ -37,8 +38,9 @@ static unsigned short self_check[]={0x90
 
 static char buf[PROC_BLOCK_SIZE];
 
-static void _fput_dword(const unsigned long l, FILE *stream)
+static void _fput_dword(const unsigned long w, FILE *stream)
 {
+ uint32_t l = (uint32_t)w;
 #ifdef WORDS_BIGENDIAN
  fputc(l    ,stream);
  fputc(l>>8 ,stream);

cvs diff -r1.1 -r1.2 pkgsrc/archivers/arj/patches/patch-decode.c (expand / switch to unified diff)

--- pkgsrc/archivers/arj/patches/patch-decode.c 2015/04/12 15:54:02 1.1
+++ pkgsrc/archivers/arj/patches/patch-decode.c 2022/01/08 14:43:09 1.2
@@ -1,28 +1,59 @@ @@ -1,28 +1,59 @@
1$NetBSD: patch-decode.c,v 1.1 2015/04/12 15:54:02 tnn Exp $ 1$NetBSD: patch-decode.c,v 1.2 2022/01/08 14:43:09 tnn Exp $
2 2
3Fix CVE-2015-2782. Via Debian security-afl.patch. 3Fix CVE-2015-2782. Via Debian security-afl.patch.
4 4
5--- decode.c.orig 2003-04-12 16:15:58.000000000 +0000 5Fix out-of-bounds read via Debian out-of-bounds-read.patch.
 6
 7--- decode.c.orig 2022-01-08 14:27:21.037706349 +0000
6+++ decode.c 8+++ decode.c
7@@ -255,7 +255,7 @@ void read_pt_len(int nn, int nbit, int i 9@@ -255,7 +255,7 @@ void read_pt_len(int nn, int nbit, int i
8 if(i==i_special) 10 if(i==i_special)
9 { 11 {
10 c=getbits(2); 12 c=getbits(2);
11- while(--c>=0) 13- while(--c>=0)
12+ while(--c>=0&&i<nn) 14+ while(--c>=0&&i<nn)
13 pt_len[i++]=0; 15 pt_len[i++]=0;
14 } 16 }
15 } 17 }
16@@ -314,10 +314,10 @@ void read_c_len() 18@@ -314,10 +314,10 @@ void read_c_len()
17 c=getbits(CBIT); 19 c=getbits(CBIT);
18 c+=20; 20 c+=20;
19 } 21 }
20- while(--c>=0) 22- while(--c>=0)
21+ while(--c>=0&&i<NC) 23+ while(--c>=0&&i<NC)
22 c_len[i++]=0; 24 c_len[i++]=0;
23 } 25 }
24- else 26- else
25+ else if (i<NC) 27+ else if (i<NC)
26 c_len[i++]=(unsigned char)(c-2); 28 c_len[i++]=(unsigned char)(c-2);
27 } 29 }
28 while(i<NC) 30 while(i<NC)
 31@@ -416,10 +416,10 @@ static void NEAR decode_end()
 32
 33 void decode(int action)
 34 {
 35- short i;
 36- short r;
 37- short c;
 38- static short j;
 39+ int i;
 40+ int r;
 41+ int c;
 42+ static int j;
 43
 44 #if SFX_LEVEL>=ARJSFXV
 45 if(!setjmp(decode_proc))
 46@@ -450,9 +450,12 @@ void decode(int action)
 47 {
 48 j=c-(UCHAR_MAX+1-THRESHOLD);
 49 count-=(unsigned long)j;
 50- i=r-decode_p()-1;
 51+ int P = decode_p();
 52+ i=r-P-1;
 53 if(i<0)
 54 i+=DICSIZ;
 55+ if(i<0)
 56+ goto termination;
 57 if(r>i&&r<DICSIZ-MAXMATCH-1)
 58 {
 59 while(--j>=0)