Date: Tue, 19 Aug 2003 21:40:37 +0200 (CEST) From: Simon Barner <barner@in.tum.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/55767: [patch] Unbreak port: archivers/libcabinet Message-ID: <20030819194037.B5F8838EA7@zi025.glhnet.mhn.de> Resent-Message-ID: <200308200941.h7K9ff0F090659@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 55767 >Category: ports >Synopsis: [patch] Unbreak port: archivers/libcabinet >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Wed Aug 20 02:41:41 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Simon Barner >Release: FreeBSD 4.8-STABLE i386 >Organization: >Environment: System: FreeBSD zi025.glhnet.mhn.de 4.8-STABLE FreeBSD 4.8-STABLE #0: Thu Aug 7 04:04:01 CEST 2003 toor@zi025.glhnet.mhn.de:/usr/src/sys/compile/KISTE i386 >Description: 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. >How-To-Repeat: >Fix: The old patches patch-aa and patch-ab are obsolete now, the third one (patch-cftypes.cpp) is updated, and there are some new patches. Simply remove files/* and use the contents of this shar instead: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # patch-Makefile # patch-bstring.cpp # patch-bstring.h # patch-cfcreate.cpp # patch-cfdblock.cpp # patch-cffolder.cpp # patch-cffolder.h # patch-cfheader.cpp # patch-cfreader.cpp # patch-cftypes.cpp # patch-cftypes.h # patch-listcap.cpp # echo x - patch-Makefile sed 's/^X//' >patch-Makefile << 'END-of-patch-Makefile' X--- Makefile.orig Tue Aug 19 18:15:11 2003 X+++ Makefile Tue Aug 19 18:33:06 2003 X@@ -0,0 +1,16 @@ X+NOPROFILE= true X+CXXFLAGS+= -Wno-deprecated X+LIB= cabinet X+LIBDIR= ${PREFIX}/lib X+INCSDIR= ${PREFIX}/include/cabinet X+INCDIR= ${INCSDIR} # for pre-bsd.incs.mk API X+SHLIB_MAJOR= 1 X+SHLIB_MINOR= 0 X+SRCS= bstring.cpp cfcreate.cpp cfdblock.cpp cffdrmgr.cpp cffile.cpp \ X+ cffolder.cpp cfheader.cpp cfreader.cpp cftypes.cpp object.cpp X+INCS= bstring.h cfcreate.h cfdblock.h cffdrmgr.h cffile.h cffolder.h \ X+ cfheader.h cfreader.h cftypes.h darray.h dos_comp.h object.hpp \ X+ queue.hpp X+LDADD= -lz X+ X+.include <bsd.lib.mk> END-of-patch-Makefile echo x - patch-bstring.cpp sed 's/^X//' >patch-bstring.cpp << 'END-of-patch-bstring.cpp' X--- bstring.cpp.orig Sun Oct 24 13:29:53 1999 X+++ bstring.cpp Tue Aug 19 18:17:32 2003 X@@ -91,7 +91,7 @@ X X b_string b_string::operator + (const char* s) X { X- b_string temp = str; X+ b_string temp (str); X return temp += s; X } X X@@ -150,7 +150,7 @@ X if(strlen(str) < strlen(s)) // If more memory is needed X *this = s; // Use assign function X else // If stpcpy can be used X- stpcpy(str, s); // Copy s into str X+ strcpy(str, s); // Copy s into str X } X X return *this; // Return a refrence to this object X@@ -217,4 +217,4 @@ X X //*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ X X-#endif X\ No newline at end of file X+#endif END-of-patch-bstring.cpp echo x - patch-bstring.h sed 's/^X//' >patch-bstring.h << 'END-of-patch-bstring.h' X--- bstring.h.orig Tue Aug 19 18:15:26 2003 X+++ bstring.h Tue Aug 19 18:16:08 2003 X@@ -28,6 +28,9 @@ X #include <fstream.h> X #include "dos_comp.h" X X+using std::ostream; X+using std::istream; X+ X ////////////////////////////////////////////////////////////////////////////// X X class b_string END-of-patch-bstring.h echo x - patch-cfcreate.cpp sed 's/^X//' >patch-cfcreate.cpp << 'END-of-patch-cfcreate.cpp' X--- cfcreate.cpp.orig Sun Oct 24 13:29:53 1999 X+++ cfcreate.cpp Tue Aug 19 21:16:05 2003 X@@ -29,6 +29,8 @@ X #include <unistd.h> X #endif X X+using std::ios; X+ X ///////////////////////////////////////*************************************** X X int cfc_fileinfo::write_entry(ostream& out) X@@ -129,7 +131,7 @@ X } X } X X- if(fstat(in.rdbuf()->fd(), &statbuf) != 0) return FSTAT_FAILURE; X+ if(stat(fname, &statbuf) != 0) return FSTAT_FAILURE; X #ifndef unix X if(getftime(in.rdbuf()->fd(), &datetime) != 0) return GETTIME_FAILURE; X #endif X@@ -194,7 +196,7 @@ X unprocessed_data = NULL; // Reset buffer holder X unprocessed_data_len = 0u; X X- if(in.read(buf + bytesread, len - bytesread).bad()) X+ if(in.read((char*)buf + bytesread, len - bytesread).bad()) X { X delete[] buf; X buf = NULL; X@@ -272,7 +274,7 @@ X return WRITE_ERROR; X } X X- tempfile->write(compdata, blockinfo.compressed_len); X+ tempfile->write((char*)compdata, blockinfo.compressed_len); X processed_bytes += sizeof(blockinfo) + blockinfo.compressed_len; X if(compdata != data) delete[] compdata; // If buffer was allocated, free it X data_blocks++; // Incriment block counter END-of-patch-cfcreate.cpp echo x - patch-cfdblock.cpp sed 's/^X//' >patch-cfdblock.cpp << 'END-of-patch-cfdblock.cpp' X--- cfdblock.cpp.orig Tue Aug 19 18:22:14 2003 X+++ cfdblock.cpp Tue Aug 19 18:23:24 2003 X@@ -124,7 +124,7 @@ X ra_size = cab_header.get_datablock_ra_size(); X reserved_area = new byte[ra_size]; X X- if(in.read(reserved_area, ra_size).bad()) X+ if(in.read((char*)reserved_area, ra_size).bad()) X { X return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF; X } X@@ -154,7 +154,7 @@ X X if(ra_size) // If reserve area, write it X { X- if(out.write(reserved_area, ra_size).fail()) return WRITE_ERROR; X+ if(out.write((char*)reserved_area, ra_size).fail()) return WRITE_ERROR; X } X // write data to stream X // if(out.write(compressed_data, compressed_size).bad()) return WRITE_ERROR; END-of-patch-cfdblock.cpp echo x - patch-cffolder.cpp sed 's/^X//' >patch-cffolder.cpp << 'END-of-patch-cffolder.cpp' X--- cffolder.cpp.orig Tue Aug 19 18:23:48 2003 X+++ cffolder.cpp Tue Aug 19 18:24:14 2003 X@@ -70,7 +70,7 @@ X ra_size = cab_header.get_folder_ra_size(); X reserved_area = new byte[ra_size]; X X- if(in.read(reserved_area, ra_size).bad()) X+ if(in.read((char*)reserved_area, ra_size).bad()) X { X return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF; X } X@@ -90,7 +90,7 @@ X X if(ra_size) // If reserved area present X { X- if(out.write(reserved_area, ra_size).fail()) { return WRITE_ERROR; } X+ if(out.write((char*)reserved_area, ra_size).fail()) { return WRITE_ERROR; } X } X X return OK; END-of-patch-cffolder.cpp echo x - patch-cffolder.h sed 's/^X//' >patch-cffolder.h << 'END-of-patch-cffolder.h' X--- cffolder.h.orig Tue Aug 19 18:30:59 2003 X+++ cffolder.h Tue Aug 19 18:31:08 2003 X@@ -89,4 +89,5 @@ X X //////////////////////////////////////////////////////////////////////////////// X X-#endif X\ No newline at end of file X+#endif X+ END-of-patch-cffolder.h echo x - patch-cfheader.cpp sed 's/^X//' >patch-cfheader.cpp << 'END-of-patch-cfheader.cpp' X--- cfheader.cpp.orig Tue Aug 19 18:24:35 2003 X+++ cfheader.cpp Tue Aug 19 18:28:27 2003 X@@ -24,11 +24,14 @@ X #include "cfheader.h" X X #ifdef unix X-#include <strstream.h> X+#include <strstream> X #else X #include <strstrea.h> X #endif X X+using std::ostrstream; X+using std::ends; X+ X ////////////////////////////////////////**************************************** X X // Initializes a valid fixed cabinet header X@@ -127,7 +130,7 @@ X { X reserved_area = new byte[cabinet_ra_size]; X X- if(in.read(reserved_area, cabinet_ra_size).bad()) X+ if(in.read((char*)reserved_area, cabinet_ra_size).bad()) X { X return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF; X } X@@ -172,7 +175,7 @@ X X if(cabinet_ra_size > 0) // If has cabinet reserved area X { X- if(out.write(reserved_area, cabinet_ra_size).fail()) X+ if(out.write((char*)reserved_area, cabinet_ra_size).fail()) X { X return WRITE_ERROR; X } X@@ -210,4 +213,4 @@ X X ////////////////////////////////////////**************************************** X X-#endif X\ No newline at end of file X+#endif END-of-patch-cfheader.cpp echo x - patch-cfreader.cpp sed 's/^X//' >patch-cfreader.cpp << 'END-of-patch-cfreader.cpp' X--- cfreader.cpp.orig Tue Aug 19 18:28:46 2003 X+++ cfreader.cpp Tue Aug 19 18:29:10 2003 X@@ -31,6 +31,8 @@ X #include "cfheader.h" X #include "cfreader.h" X X+using std::ios; X+ X ////////////////////////////////////////**************************************** X X int cabinet_reader::open(const char* fname) END-of-patch-cfreader.cpp echo x - patch-cftypes.cpp sed 's/^X//' >patch-cftypes.cpp << 'END-of-patch-cftypes.cpp' X--- cftypes.cpp.orig Sun Oct 24 08:13:29 1999 X+++ cftypes.cpp Tue Aug 19 19:35:32 2003 X@@ -138,15 +138,20 @@ X X int io_read(istream& in, byte* buf, word len) X { X- while(len > MAXINT) X+ // replaced MAXINT with MAXSHORT, since len is of type X+ // word == unsigned short int X+ // X+ // TODO: please review this, since IMO the while-loop is X+ // never entered X+ while (len > MAXSHORT) X { X- if(in.read(buf, MAXINT).bad()) X+ if(in.read((char*)buf, MAXSHORT).bad()) X return (in.fail()) ? READ_ERROR : UNEXPECTED_EOF; X- len -= (word) MAXINT; X- buf += (word) MAXINT; X+ len -= (word) MAXSHORT; X+ buf += (word) MAXSHORT; X } X X- return (in.read(buf, (int) len).bad()) X+ return (in.read((char*)buf, (int) len).bad()) X ? (in.fail()) ? READ_ERROR : UNEXPECTED_EOF : OK; X } X X@@ -154,14 +159,19 @@ X X int io_write(ostream& out, const byte* buf, word len) X { X- while(len > MAXINT) X+ // replaced MAXINT with MAXSHORT, since len is of type X+ // word == unsigned short int X+ // X+ // TODO: please review this, since IMO the while-loop is X+ // never entered X+ while(len > MAXSHORT) X { X- if(out.write(buf, MAXINT).fail()) return WRITE_ERROR; X- len -= (word) MAXINT; X- buf += (word) MAXINT; X+ if(out.write((char*)buf, MAXSHORT).fail()) return WRITE_ERROR; X+ len -= (word) MAXSHORT; X+ buf += (word) MAXSHORT; X } X X- return (out.write(buf, (int) len).fail()) ? WRITE_ERROR : OK; X+ return (out.write((char*)buf, (int) len).fail()) ? WRITE_ERROR : OK; X } X X //*****************************************************************************/ END-of-patch-cftypes.cpp echo x - patch-cftypes.h sed 's/^X//' >patch-cftypes.h << 'END-of-patch-cftypes.h' X--- cftypes.h.orig Tue Aug 19 18:17:55 2003 X+++ cftypes.h Tue Aug 19 18:18:54 2003 X@@ -18,6 +18,9 @@ X X #include <fstream.h> X X+using std::istream; X+using std::ostream; X+ X typedef unsigned char byte; X typedef unsigned short int word; X typedef unsigned long int dword; END-of-patch-cftypes.h echo x - patch-listcap.cpp sed 's/^X//' >patch-listcap.cpp << 'END-of-patch-listcap.cpp' X--- listcab.cpp.orig Tue Aug 19 20:42:27 2003 X+++ listcab.cpp Tue Aug 19 20:49:27 2003 X@@ -47,13 +47,19 @@ X cerr << "New Folder Error: " << retval << endl; X return 1; X } X- X+ int n; X do{ X cout << "Enter filename: "; X- gets(filename); X- X- if(strlen(filename) > 0) X+ fgets(filename, 256, stdin); X+ n = strlen (filename); X+ X+ if (n == 1 && filename[0] == '\n') X+ n = 0; X+ X+ if(n > 0) X { X+ if (filename[n-1] == '\n') X+ filename[n-1] = '\0'; X if((retval = cab.add_file(filename)) != OK) X { X perror("read"); X@@ -62,10 +68,13 @@ X return 1; X } X } X- }while(strlen(filename) > 0); X+ }while(n > 0); X X cout << "Enter filename for cabinet: "; X- gets(filename); X+ fgets(filename, 256, stdin); X+ n = strlen (filename); X+ if (n > 0 && filename[n-1] == '\n') X+ filename[n-1] = '\0'; X X if((retval = cab.close(filename)) != OK) X { END-of-patch-listcap.cpp exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030819194037.B5F8838EA7>