aboutsummaryrefslogtreecommitdiffstats
path: root/archivers/libcabinet
diff options
context:
space:
mode:
authoredwin <edwin@FreeBSD.org>2003-08-31 21:09:31 +0800
committeredwin <edwin@FreeBSD.org>2003-08-31 21:09:31 +0800
commit7f55413109fbf48827fb23b322001334a1120aed (patch)
tree306043a60ce6c23567a6af8bc6576ab44cdb6262 /archivers/libcabinet
parented7f213e388dc83faad501ac3e4d946ff1678042 (diff)
downloadfreebsd-ports-graphics-7f55413109fbf48827fb23b322001334a1120aed.tar.gz
freebsd-ports-graphics-7f55413109fbf48827fb23b322001334a1120aed.tar.zst
freebsd-ports-graphics-7f55413109fbf48827fb23b322001334a1120aed.zip
[patch] Unbreak port: archivers/libcabinet
This port did not build with gcc 3.3.1. I also fixed a possible buffer overflow (they used gets() to read from stdin). Please review the patch file ``patch-cftypes.cpp'' with extra care, since I am not sure whether this makes sense (2 positions in the file, marked with ``TODO'' - thanks. Also added some lines in cftypes.cpp to overcome the absence of values.h on -current. PR: ports/55767 Submitted by: Simon Barner <barner@in.tum.de>
Diffstat (limited to 'archivers/libcabinet')
-rw-r--r--archivers/libcabinet/Makefile8
-rw-r--r--archivers/libcabinet/files/patch-Makefile19
-rw-r--r--archivers/libcabinet/files/patch-bstring.cpp11
-rw-r--r--archivers/libcabinet/files/patch-bstring.h12
-rw-r--r--archivers/libcabinet/files/patch-cfcreate.cpp38
-rw-r--r--archivers/libcabinet/files/patch-cfdblock.cpp20
-rw-r--r--archivers/libcabinet/files/patch-cffile.h9
-rw-r--r--archivers/libcabinet/files/patch-cffolder.cpp20
-rw-r--r--archivers/libcabinet/files/patch-cffolder.h10
-rw-r--r--archivers/libcabinet/files/patch-cfheader.cpp43
-rw-r--r--archivers/libcabinet/files/patch-cfreader.cpp11
-rw-r--r--archivers/libcabinet/files/patch-cftypes.cpp59
-rw-r--r--archivers/libcabinet/files/patch-cftypes.h12
-rw-r--r--archivers/libcabinet/files/patch-darray.h9
-rw-r--r--archivers/libcabinet/files/patch-listcap.cpp42
15 files changed, 298 insertions, 25 deletions
diff --git a/archivers/libcabinet/Makefile b/archivers/libcabinet/Makefile
index e4f9112ded1..3bac89185c6 100644
--- a/archivers/libcabinet/Makefile
+++ b/archivers/libcabinet/Makefile
@@ -19,12 +19,6 @@ INSTALLS_SHLIB= yes
SRCFILE= ${WRKSRC}/listcab.cpp
PROGFILE= ${SRCFILE:S/.cpp$//}
-.include <bsd.port.pre.mk>
-
-.if ${OSVERSION} >= 500035
-BROKEN= "Does not compile on 5.0"
-.endif
-
post-build:
${CXX} ${CXXFLAGS} -o ${PROGFILE} ${SRCFILE} -L${WRKSRC} -lcabinet
@@ -34,4 +28,4 @@ pre-install:
post-install:
${INSTALL_PROGRAM} ${PROGFILE} ${PREFIX}/bin
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/archivers/libcabinet/files/patch-Makefile b/archivers/libcabinet/files/patch-Makefile
new file mode 100644
index 00000000000..c649df16146
--- /dev/null
+++ b/archivers/libcabinet/files/patch-Makefile
@@ -0,0 +1,19 @@
+--- Makefile.orig Tue Aug 19 18:15:11 2003
++++ Makefile Tue Aug 19 18:33:06 2003
+@@ -0,0 +1,16 @@
++NOPROFILE= true
++CXXFLAGS+= -Wno-deprecated
++LIB= cabinet
++LIBDIR= ${PREFIX}/lib
++INCSDIR= ${PREFIX}/include/cabinet
++INCDIR= ${INCSDIR} # for pre-bsd.incs.mk API
++SHLIB_MAJOR= 1
++SHLIB_MINOR= 0
++SRCS= bstring.cpp cfcreate.cpp cfdblock.cpp cffdrmgr.cpp cffile.cpp \
++ cffolder.cpp cfheader.cpp cfreader.cpp cftypes.cpp object.cpp
++INCS= bstring.h cfcreate.h cfdblock.h cffdrmgr.h cffile.h cffolder.h \
++ cfheader.h cfreader.h cftypes.h darray.h dos_comp.h object.hpp \
++ queue.hpp
++LDADD= -lz
++
++.include <bsd.lib.mk>
diff --git a/archivers/libcabinet/files/patch-bstring.cpp b/archivers/libcabinet/files/patch-bstring.cpp
new file mode 100644
index 00000000000..8a1d6e91d4f
--- /dev/null
+++ b/archivers/libcabinet/files/patch-bstring.cpp
@@ -0,0 +1,11 @@
+--- bstring.cpp.orig Sun Aug 31 05:49:53 2003
++++ bstring.cpp Sun Aug 31 05:49:53 2003
+@@ -91,7 +91,7 @@
+
+ b_string b_string::operator + (const char* s)
+ {
+- b_string temp = str;
++ b_string temp (str);
+ return temp += s;
+ }
+
diff --git a/archivers/libcabinet/files/patch-bstring.h b/archivers/libcabinet/files/patch-bstring.h
new file mode 100644
index 00000000000..384a815aa1c
--- /dev/null
+++ b/archivers/libcabinet/files/patch-bstring.h
@@ -0,0 +1,12 @@
+--- bstring.h.orig Tue Aug 19 18:15:26 2003
++++ bstring.h Tue Aug 19 18:16:08 2003
+@@ -28,6 +28,9 @@
+ #include <fstream.h>
+ #include "dos_comp.h"
+
++using std::ostream;
++using std::istream;
++
+ //////////////////////////////////////////////////////////////////////////////
+
+ class b_string
diff --git a/archivers/libcabinet/files/patch-cfcreate.cpp b/archivers/libcabinet/files/patch-cfcreate.cpp
new file mode 100644
index 00000000000..2e7bc80ea31
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cfcreate.cpp
@@ -0,0 +1,38 @@
+--- cfcreate.cpp.orig Sun Oct 24 13:29:53 1999
++++ cfcreate.cpp Tue Aug 19 21:16:05 2003
+@@ -29,6 +29,8 @@
+ #include <unistd.h>
+ #endif
+
++using std::ios;
++
+ ///////////////////////////////////////***************************************
+
+ int cfc_fileinfo::write_entry(ostream& out)
+@@ -129,7 +131,7 @@
+ }
+ }
+
+- if(fstat(in.rdbuf()->fd(), &statbuf) != 0) return FSTAT_FAILURE;
++ if(stat(fname, &statbuf) != 0) return FSTAT_FAILURE;
+ #ifndef unix
+ if(getftime(in.rdbuf()->fd(), &datetime) != 0) return GETTIME_FAILURE;
+ #endif
+@@ -194,7 +196,7 @@
+ unprocessed_data = NULL; // Reset buffer holder
+ unprocessed_data_len = 0u;
+
+- if(in.read(buf + bytesread, len - bytesread).bad())
++ if(in.read((char*)buf + bytesread, len - bytesread).bad())
+ {
+ delete[] buf;
+ buf = NULL;
+@@ -272,7 +274,7 @@
+ return WRITE_ERROR;
+ }
+
+- tempfile->write(compdata, blockinfo.compressed_len);
++ tempfile->write((char*)compdata, blockinfo.compressed_len);
+ processed_bytes += sizeof(blockinfo) + blockinfo.compressed_len;
+ if(compdata != data) delete[] compdata; // If buffer was allocated, free it
+ data_blocks++; // Incriment block counter
diff --git a/archivers/libcabinet/files/patch-cfdblock.cpp b/archivers/libcabinet/files/patch-cfdblock.cpp
new file mode 100644
index 00000000000..f9e89e337a3
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cfdblock.cpp
@@ -0,0 +1,20 @@
+--- cfdblock.cpp.orig Tue Aug 19 18:22:14 2003
++++ cfdblock.cpp Tue Aug 19 18:23:24 2003
+@@ -124,7 +124,7 @@
+ ra_size = cab_header.get_datablock_ra_size();
+ reserved_area = new byte[ra_size];
+
+- if(in.read(reserved_area, ra_size).bad())
++ if(in.read((char*)reserved_area, ra_size).bad())
+ {
+ return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF;
+ }
+@@ -154,7 +154,7 @@
+
+ if(ra_size) // If reserve area, write it
+ {
+- if(out.write(reserved_area, ra_size).fail()) return WRITE_ERROR;
++ if(out.write((char*)reserved_area, ra_size).fail()) return WRITE_ERROR;
+ }
+ // write data to stream
+ // if(out.write(compressed_data, compressed_size).bad()) return WRITE_ERROR;
diff --git a/archivers/libcabinet/files/patch-cffile.h b/archivers/libcabinet/files/patch-cffile.h
new file mode 100644
index 00000000000..47ce44b8077
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cffile.h
@@ -0,0 +1,9 @@
+--- cffile.h.orig Sun Aug 31 05:54:08 2003
++++ cffile.h Sun Aug 31 05:54:10 2003
+@@ -161,4 +161,4 @@
+
+ ////////////////////////////////////////////////////////////////////////////////
+
+-#endif
+\ No newline at end of file
++#endif
diff --git a/archivers/libcabinet/files/patch-cffolder.cpp b/archivers/libcabinet/files/patch-cffolder.cpp
new file mode 100644
index 00000000000..74db8f57036
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cffolder.cpp
@@ -0,0 +1,20 @@
+--- cffolder.cpp.orig Tue Aug 19 18:23:48 2003
++++ cffolder.cpp Tue Aug 19 18:24:14 2003
+@@ -70,7 +70,7 @@
+ ra_size = cab_header.get_folder_ra_size();
+ reserved_area = new byte[ra_size];
+
+- if(in.read(reserved_area, ra_size).bad())
++ if(in.read((char*)reserved_area, ra_size).bad())
+ {
+ return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF;
+ }
+@@ -90,7 +90,7 @@
+
+ if(ra_size) // If reserved area present
+ {
+- if(out.write(reserved_area, ra_size).fail()) { return WRITE_ERROR; }
++ if(out.write((char*)reserved_area, ra_size).fail()) { return WRITE_ERROR; }
+ }
+
+ return OK;
diff --git a/archivers/libcabinet/files/patch-cffolder.h b/archivers/libcabinet/files/patch-cffolder.h
new file mode 100644
index 00000000000..526ea011dd1
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cffolder.h
@@ -0,0 +1,10 @@
+--- cffolder.h.orig Tue Aug 19 18:30:59 2003
++++ cffolder.h Tue Aug 19 18:31:08 2003
+@@ -89,4 +89,5 @@
+
+ ////////////////////////////////////////////////////////////////////////////////
+
+-#endif
+\ No newline at end of file
++#endif
++
diff --git a/archivers/libcabinet/files/patch-cfheader.cpp b/archivers/libcabinet/files/patch-cfheader.cpp
new file mode 100644
index 00000000000..9d06cd72d6d
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cfheader.cpp
@@ -0,0 +1,43 @@
+--- cfheader.cpp.orig Tue Aug 19 18:24:35 2003
++++ cfheader.cpp Tue Aug 19 18:28:27 2003
+@@ -24,11 +24,14 @@
+ #include "cfheader.h"
+
+ #ifdef unix
+-#include <strstream.h>
++#include <strstream>
+ #else
+ #include <strstrea.h>
+ #endif
+
++using std::ostrstream;
++using std::ends;
++
+ ////////////////////////////////////////****************************************
+
+ // Initializes a valid fixed cabinet header
+@@ -127,7 +130,7 @@
+ {
+ reserved_area = new byte[cabinet_ra_size];
+
+- if(in.read(reserved_area, cabinet_ra_size).bad())
++ if(in.read((char*)reserved_area, cabinet_ra_size).bad())
+ {
+ return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF;
+ }
+@@ -172,7 +175,7 @@
+
+ if(cabinet_ra_size > 0) // If has cabinet reserved area
+ {
+- if(out.write(reserved_area, cabinet_ra_size).fail())
++ if(out.write((char*)reserved_area, cabinet_ra_size).fail())
+ {
+ return WRITE_ERROR;
+ }
+@@ -210,4 +213,4 @@
+
+ ////////////////////////////////////////****************************************
+
+-#endif
+\ No newline at end of file
++#endif
diff --git a/archivers/libcabinet/files/patch-cfreader.cpp b/archivers/libcabinet/files/patch-cfreader.cpp
new file mode 100644
index 00000000000..aad3c1e4817
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cfreader.cpp
@@ -0,0 +1,11 @@
+--- cfreader.cpp.orig Tue Aug 19 18:28:46 2003
++++ cfreader.cpp Tue Aug 19 18:29:10 2003
+@@ -31,6 +31,8 @@
+ #include "cfheader.h"
+ #include "cfreader.h"
+
++using std::ios;
++
+ ////////////////////////////////////////****************************************
+
+ int cabinet_reader::open(const char* fname)
diff --git a/archivers/libcabinet/files/patch-cftypes.cpp b/archivers/libcabinet/files/patch-cftypes.cpp
index b492d5acfae..c39330eb96f 100644
--- a/archivers/libcabinet/files/patch-cftypes.cpp
+++ b/archivers/libcabinet/files/patch-cftypes.cpp
@@ -1,47 +1,70 @@
-
-$FreeBSD$
-
---- cftypes.cpp 2002/10/01 11:38:22 1.1
-+++ cftypes.cpp 2002/10/01 11:39:37
-@@ -10,7 +10,7 @@
+--- cftypes.cpp.orig Sat Oct 23 23:13:29 1999
++++ cftypes.cpp Sun Aug 31 06:07:25 2003
+@@ -10,7 +10,15 @@
#ifndef __CFTYPES_CPP__
#define __CFTYPES_CPP__
-#include <values.h>
++#ifndef MAXSHORT
++#define BITSPERBYTE 8
++#define BITS(type) (BITSPERBYTE * (int)sizeof(type))
++#define SHORTBITS BITS(int16_t)
++#define MINSHORT ((int16_t)(1 << (SHORTBITS - 1)))
++#define MAXSHORT ((int16_t)~MINSHORT)
++#endif
++
+#include <limits.h>
#include <fstream.h>
#include "zlib.h"
#include "cftypes.h"
-@@ -138,12 +138,12 @@
+@@ -138,15 +146,20 @@
int io_read(istream& in, byte* buf, word len)
{
- while(len > MAXINT)
-+ while(len > INT_MAX)
++ // replaced MAXINT with MAXSHORT, since len is of type
++ // word == unsigned short int
++ //
++ // TODO: please review this, since IMO the while-loop is
++ // never entered
++ while (len > MAXSHORT)
{
- if(in.read(buf, MAXINT).bad())
-+ if(in.read(buf, INT_MAX).bad())
++ if(in.read((char*)buf, MAXSHORT).bad())
return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF;
- len -= (word) MAXINT;
- buf += (word) MAXINT;
-+ len -= (word) INT_MAX;
-+ buf += (word) INT_MAX;
++ len -= (word) MAXSHORT;
++ buf += (word) MAXSHORT;
}
- return (in.read(buf, (int) len).bad())
-@@ -154,11 +154,11 @@
+- return (in.read(buf, (int) len).bad())
++ return (in.read((char*)buf, (int) len).bad())
+ ? (in.fail()) ? READ_ERROR : UNEXPECTED_EOF : OK;
+ }
+
+@@ -154,14 +167,19 @@
int io_write(ostream& out, const byte* buf, word len)
{
- while(len > MAXINT)
-+ while(len > INT_MAX)
++ // replaced MAXINT with MAXSHORT, since len is of type
++ // word == unsigned short int
++ //
++ // TODO: please review this, since IMO the while-loop is
++ // never entered
++ while(len > MAXSHORT)
{
- if(out.write(buf, MAXINT).fail()) return WRITE_ERROR;
- len -= (word) MAXINT;
- buf += (word) MAXINT;
-+ if(out.write(buf, INT_MAX).fail()) return WRITE_ERROR;
-+ len -= (word) INT_MAX;
-+ buf += (word) INT_MAX;
++ if(out.write((char*)buf, MAXSHORT).fail()) return WRITE_ERROR;
++ len -= (word) MAXSHORT;
++ buf += (word) MAXSHORT;
}
- return (out.write(buf, (int) len).fail()) ? WRITE_ERROR : OK;
+- return (out.write(buf, (int) len).fail()) ? WRITE_ERROR : OK;
++ return (out.write((char*)buf, (int) len).fail()) ? WRITE_ERROR : OK;
+ }
+
+ //*****************************************************************************/
diff --git a/archivers/libcabinet/files/patch-cftypes.h b/archivers/libcabinet/files/patch-cftypes.h
new file mode 100644
index 00000000000..714ac4462a2
--- /dev/null
+++ b/archivers/libcabinet/files/patch-cftypes.h
@@ -0,0 +1,12 @@
+--- cftypes.h.orig Tue Aug 19 18:17:55 2003
++++ cftypes.h Tue Aug 19 18:18:54 2003
+@@ -18,6 +18,9 @@
+
+ #include <fstream.h>
+
++using std::istream;
++using std::ostream;
++
+ typedef unsigned char byte;
+ typedef unsigned short int word;
+ typedef unsigned long int dword;
diff --git a/archivers/libcabinet/files/patch-darray.h b/archivers/libcabinet/files/patch-darray.h
new file mode 100644
index 00000000000..2e28f3f879f
--- /dev/null
+++ b/archivers/libcabinet/files/patch-darray.h
@@ -0,0 +1,9 @@
+--- darray.h.orig Sun Aug 31 05:55:31 2003
++++ darray.h Sun Aug 31 05:55:32 2003
+@@ -155,4 +155,4 @@
+
+ ///////////////////////////////////////***************************************
+
+-#endif
+\ No newline at end of file
++#endif
diff --git a/archivers/libcabinet/files/patch-listcap.cpp b/archivers/libcabinet/files/patch-listcap.cpp
new file mode 100644
index 00000000000..409e1f6c0e5
--- /dev/null
+++ b/archivers/libcabinet/files/patch-listcap.cpp
@@ -0,0 +1,42 @@
+--- listcab.cpp.orig Tue Aug 19 20:42:27 2003
++++ listcab.cpp Tue Aug 19 20:49:27 2003
+@@ -47,13 +47,19 @@
+ cerr << "New Folder Error: " << retval << endl;
+ return 1;
+ }
+-
++ int n;
+ do{
+ cout << "Enter filename: ";
+- gets(filename);
+-
+- if(strlen(filename) > 0)
++ fgets(filename, 256, stdin);
++ n = strlen (filename);
++
++ if (n == 1 && filename[0] == '\n')
++ n = 0;
++
++ if(n > 0)
+ {
++ if (filename[n-1] == '\n')
++ filename[n-1] = '\0';
+ if((retval = cab.add_file(filename)) != OK)
+ {
+ perror("read");
+@@ -62,10 +68,13 @@
+ return 1;
+ }
+ }
+- }while(strlen(filename) > 0);
++ }while(n > 0);
+
+ cout << "Enter filename for cabinet: ";
+- gets(filename);
++ fgets(filename, 256, stdin);
++ n = strlen (filename);
++ if (n > 0 && filename[n-1] == '\n')
++ filename[n-1] = '\0';
+
+ if((retval = cab.close(filename)) != OK)
+ {