Skip to content

Commit 7dca0e6

Browse files
author
jedwin
committed
Initial import (0.37)
0 parents  commit 7dca0e6

27 files changed

+49208
-0
lines changed

AUTHORS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Jed Wing <jedwin@ugcs.caltech.edu>
2+
includes modified LZX code from cabextract-0.5 by Stuart Caie.
3+
4+
Thanks to:
5+
iDEFENSE for reporting the stack overflow vulnerability.
6+
Palasik Sandor for reporting and fixing the LZX buffer overrun vulnerability.
7+
David Huseby for enhancements to the chm_enumerate functionality.
8+
Vitaly Bursov for compilation fixes for x86-64.
9+
Vadim Zeitlin for a patch to clean up and fix some deficiencies in the
10+
configure script.
11+
Stan Tobias for bugfixes and index-page improvement to chm_http.
12+
Andrew Hodgetts for major portability improvement.
13+
Rich Erwin for his work towards Windows CE support.
14+
Pabs for bug fixes and suggestions.
15+
Antony Dovgal for setting up autoconf/automake based build process.
16+
Ragnar Hojland Espinosa for patches to make chm_http more useful.
17+
Razvan Cojocaru for forwarding along information regarding building on OS X.
18+
Anyone else I've forgotten.

COPYING

Lines changed: 510 additions & 0 deletions
Large diffs are not rendered by default.

ChmLib-ce.zip

1.56 KB
Binary file not shown.

ChmLib-ds6.zip

6.32 KB
Binary file not shown.

INSTALL

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
CHMLIB 0.3 Installation
2+
=======================
3+
4+
-----
5+
Linux/Unix and Windows (Cygwin)
6+
-----
7+
8+
I. Relevant options:
9+
10+
CHM_MT: build library with synchronization for thread-safety
11+
CHM_USE_PREAD: use pread instead of lseek/read
12+
CHM_USE_IO64: support 64-bit file I/O
13+
14+
Modify the INSTALLPREFIX to change the installation location.
15+
16+
Except on platforms where they need to be disabled, I recommend leaving all
17+
three options enabled. OS X, however, in particular, seems to need pread
18+
and io64 disabled.
19+
20+
II. autoconf/automake-style build
21+
22+
./configure [options]
23+
make
24+
su
25+
make install
26+
27+
III. old-style (plain Makefile) build
28+
29+
cd src
30+
<edit Makefile.simple if necessary>
31+
make -f Makefile.old
32+
su
33+
make install
34+
35+
To use the library, see chm_lib.h, and the included example programs:
36+
37+
test_chmLib.c
38+
enum_chmLib.c
39+
chm_http.c
40+
41+
-------
42+
Windows (MSVC++, Win CE SDK)
43+
-------
44+
45+
I. Relevant options:
46+
47+
CHM_MT: build library with synchronization for thread-safety
48+
49+
II. Windows Standard Build
50+
51+
Unzip ChmLib-vs6.zip in the src directory, and open the ChmLib.dsw file in
52+
Developer Studio. (This was developed on Developer Studio 6. I don't know
53+
if that matters.) You may wish to enable or disable certain features by
54+
adding preprocessor defines under the project settings dialog:
55+
56+
CHM_MT: build library with synchronization for thread-safety
57+
58+
CHM_MT is enabled by default in the Windows build.
59+
60+
The resultant library is called chmlib.lib.
61+
62+
To use the library, see chm_lib.h, and the included example programs:
63+
64+
test_chmLib.c
65+
enum_chmLib.c
66+
chm_http.c
67+
68+
The example programs should also show up in the Visual Studio workspace,
69+
except for chm_http. I don't know enough about Windows network programming
70+
to try to get that one working. Other than that one, all the other examples
71+
run without any problems.
72+
73+
III. Windows CE Build
74+
75+
Unzip ChmLib-ce.zip in the src directory. I don't know much beyond that,
76+
as I have no familiarity with Windows CE, but this should be a good
77+
starting point. These project files are from Rich Erwin, who also supplied
78+
the necessary code changes to get it running.
79+
80+
Sparc (Solaris)
81+
---------------
82+
Andrew Hodgetts has gotten the library compilable and working on Sparc
83+
Solaris machines, with CPUs ranging from a Sun4m (Sparc5) up through an
84+
UltraSparcIII (SunFireV880). He has managed the compilation using both GCC and
85+
SunProC, although, he notes, some modification to the Makefile was required,
86+
since SunProC does not understand the -fPIC flag, which GCC uses for Position
87+
Independent Code.
88+
89+
MIPS (SGI Irix)
90+
---------------
91+
Andrew Hodgetts has gotten the library compilable and working on SGI MIPS
92+
machines running Irix; this was using only the standard MIPS compiler, not GCC.
93+
He reported that the -n32 flag was required in the Makefile. He also reported
94+
that the MIPS compiler was fairly verbose with the warning messages, but that
95+
the simple examples that came with the library seemed to work.
96+
97+
OS X
98+
----
99+
Apparently, various people have gotten the library compiled for OS X. From
100+
what I've heard, the secret is to disable pread and io64, and possibly to use
101+
the 'libtool' from fink, instead of the one included with the standard
102+
developers kit.
103+
104+
BSD variants
105+
----
106+
I've heard that the library has been compiled on BSD variants. I haven't
107+
heard of any particular difficulties.
108+
109+
Other Unix variants
110+
-------------------
111+
The code has been written with an eye on portability. Presently, I've only
112+
personally compiled on Linux and Windows, albeit on a variety of Linux
113+
configurations, but, as reported above, Andrew Hodgetts has reported successful
114+
use of the library on both Solaris machines and MIPS machines.. After I get
115+
version 0.3 out, I may try to get it compiling on some of the machines I have
116+
at work. This code may or may not compile out of the box with, for instance,
117+
*BSD or other Unix variants. I welcome any patches that increase the
118+
portability of this code.
119+
120+
Platforms that I have access to at work, and may attempt to support after
121+
version 0.3:
122+
123+
- AIX
124+
- maybe Tru64

Makefile.in

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
## Available defines for building chm_lib with particular options
3+
# CHM_MT: build thread-safe version of chm_lib
4+
# CHM_USE_PREAD: build chm_lib to use pread/pread64 for all I/O
5+
# CHM_USE_IO64: build chm_lib to support 64-bit file I/O
6+
#
7+
# Note: LDFLAGS must contain -lpthread if you are using -DCHM_MT.
8+
#
9+
#CFLAGS=-DCHM_MT -DCHM_USE_PREAD -DCHM_USE_IO64
10+
#CFLAGS=-DCHM_MT -DCHM_USE_PREAD -DCHM_USE_IO64 -g -DDMALLOC_DISABLE
11+
CFLAGS=@CFLAGS@ @CHM_MT@ @CHM_USE_PREAD@ @CHM_USE_IO64@ @DMALLOC_DISABLE@
12+
LDFLAGS=@LDFLAGS@
13+
prefix=@prefix@
14+
libdir=@libdir@
15+
exec_prefix=@exec_prefix@
16+
includedir=@includedir@
17+
CC=@CC@
18+
top_builddir=@top_builddir@
19+
ifeq ($(top_builddir),)
20+
top_builddir=$(shell pwd)
21+
endif
22+
srcdir=@srcdir@
23+
LIBTOOL=@LIBTOOL@
24+
EXAMPLES=@EXAMPLES@
25+
26+
all: src/libchm.la
27+
28+
examples: ${EXAMPLES}
29+
30+
src/%.lo: $(srcdir)/src/%.c
31+
${LIBTOOL} --mode=compile ${CC} -c -o $@ $^ ${CFLAGS}
32+
33+
src/libchm.la: src/chm_lib.lo src/lzx.lo
34+
${LIBTOOL} --mode=link ${CC} -o $@ $^ ${LDFLAGS} -rpath $(libdir)
35+
36+
install: src/libchm.la
37+
mkdir -p $(DESTDIR)$(prefix) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
38+
${LIBTOOL} --mode=install install -m0755 src/libchm.la $(DESTDIR)$(libdir)/
39+
install -m0644 $(srcdir)/src/chm_lib.h $(DESTDIR)$(includedir)/
40+
41+
clean:
42+
rm -fr src/libchm.la src/*.o src/*.lo .libs src/.libs src/${EXAMPLES}
43+
44+
test_chmLib: $(srcdir)/src/test_chmLib.c
45+
${CC} -o $@ $^ -I$(includedir) -L$(libdir) -lchm ${CFLAGS}
46+
47+
enum_chmLib: $(srcdir)/src/enum_chmLib.c
48+
${CC} -o $@ $^ -I$(includedir) -L$(libdir) -lchm ${CFLAGS}
49+
50+
enumdir_chmLib: $(srcdir)/src/enumdir_chmLib.c
51+
${CC} -o $@ $^ -I$(includedir) -L$(libdir) -lchm ${CFLAGS}
52+
53+
extract_chmLib: $(srcdir)/src/extract_chmLib.c
54+
${CC} -o $@ $^ -I$(includedir) -L$(libdir) -lchm ${CFLAGS}
55+
56+
chm_http: $(srcdir)/src/chm_http.c
57+
${CC} -o $@ $^ -I$(includedir) -L$(libdir) -lchm -lpthread ${CFLAGS}
58+

NEWS

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Changes from 0.36 to 0.37
2+
- Major security fix for stack overflow vulnerability:
3+
http://www.sven-tantau.de/public_files/chmlib/chmlib_20051126.txt
4+
- Corrected the broken Makefile.in.
5+
6+
Changes from 0.35 to 0.36
7+
- Major security fix (iDEFENSE Security Advisory IDEF1099 - Stack Overflow
8+
Vulnerability)
9+
- Major security fix from Palasik Sandor (LZX decompression buffer overrun)
10+
- Bugfix/enhancement from David Huseby to make the "what" flags to
11+
chm_enumerate work correctly, and to pass the flags along to the callback
12+
function (via the chmUnitInfo structure) so that the callback doesn't
13+
need to re-parse the filename.
14+
- Compilation fixes for x86-64 from Vitaly V. Bursov.
15+
- Miscellaneous fixes to the configure script, including some significant
16+
cleanup by Vadim Zeitlin. The changes from Vadim should also allow the
17+
configure script to correctly configure the build on OS X, where it was
18+
previously failing to note that pread64 doesn't work.
19+
- Minor update to the Makefile.in to do a mkdir before the install, in case
20+
the specified INSTALLPREFIX directory is non-existent
21+
22+
Changes from 0.32 to 0.35
23+
- UTF-8 filenames, while still not handled correctly, are handled a little
24+
more gracefully. That is to say, the library doesn't fail to open files
25+
with filenames using characters outside the ASCII subset. I'm very
26+
interested in any information as to the "right" way to handle filenames
27+
of this sort.
28+
- Files not containing a compressed section are handled properly, such as
29+
.chw files. These files seem to contain information about compression,
30+
but the information is invalid or empty. The library deals gracefully
31+
with this now.
32+
- Files compressed with different options were not being decompressed
33+
properly. In particular, if the "reset interval" for the compressed
34+
section was other than 2 block sizes, it could fail to read some of the
35+
files.
36+
- The caching system was improved slightly, in conjunction with this
37+
previous bugfix.
38+
39+
Changes from 0.3 to 0.32:
40+
- [Rich Erwin] Minor portability fixes for Windows CE.
41+
- [Pabs] Minor bugfix regarding detecting directory entries versus empty files.
42+
- [Antony Dovgal] autoconf-based build process
43+
- [Ragnar Hojland Espinosa] Feature additions for chm_http:
44+
* Use SO_REUSEADDR
45+
* Allow --bind= and --port= command line arguments
46+
- Simple makefile has been fixed (finally) to use gcc instead of gcc-3.2. (Sorry, everybody!)
47+
48+
Changes from 0.2 to 0.3:
49+
50+
- initial attempt at portability to Win32.
51+
- bugfixes from Stan Tobias:
52+
* memory corruption error with caching system
53+
* case insensitivity, to match with the Windows semantics
54+
- modification to chm_http by Stan Tobias:
55+
* when the user requests the page '/', they get a page with links to
56+
all of the files in the archive
57+
- Andrew Hodgetts has ported the library to Solaris and Irix. See README for details.
58+
- Stuart Caie has granted permission to relicense under the LGPL.

README

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
CHMLIB 0.37
2+
===========
3+
4+
-------
5+
SUMMARY
6+
-------
7+
chmlib is a small library designed for accessing MS ITSS files. The ITSS file
8+
format is used for Microsoft Html Help files (.chm), which have been the
9+
predominant medium for software documentation from Microsoft during the past
10+
several years, having superceded the previously used .hlp file format.
11+
12+
Note that this is NOT the same as the OLE structured storage file format used
13+
by MS Excel, Word, and so on. Instead, it is a different file format which
14+
fulfills a similar purpose. Both file formats may be accessed via instances
15+
of the IStorage COM interface, which is essentially an "acts like a
16+
filesystem" interface.
17+
18+
-------
19+
FILE FORMAT SUPPORT
20+
-------
21+
22+
Lookup of files in the archive is supported, and should be relatively quick.
23+
Reading of files in the archive is also supported.
24+
Writing is not supported, but may be added in the future.
25+
26+
In terms of support for the ITSS file format, there are a few places in which
27+
the support provided by this library is not fully general:
28+
29+
1. ITSS files whose names contain UTF-8 characters which are not part of the
30+
ASCII subset will not currently be dealt with gracefully. Currently, the
31+
filenames are not converted from UTF-8, but are instead returned as-is. I'm
32+
very interested in hearing any suggestions as to the "right" way to handle
33+
this.
34+
35+
2. Only version 3 ITSS files are supported at present, though some work has
36+
gone towards divining the differences between different versions of the
37+
file format. It is possible that version 2 ITSS files might work properly
38+
with this library, but unconfirmed.
39+
40+
3. Archives larger than 4 GB should be supported just fine, but if they
41+
contain files larger than 4GB, this library may break. Fortunately, this
42+
seems somewhat unlikely.
43+
44+
If you run into .chm files (or files you suspect are ITSS files) that this
45+
library doesn't work with, please contact me so I can fix the library.
46+
47+
-------
48+
PORTABILITY
49+
-------
50+
51+
This software was originally developed on a Intel x86 Debian Linux machine,
52+
using gcc 3.0. It has since been compiled on various flavors of RedHat as
53+
well, and using versions of gcc from 2.95 through 3.2. Basic Win32 support
54+
should be in this release. (While a port to Win32 may _seem_ like a funny
55+
idea, given that Windows ships with libraries for CHM access, it turns out that
56+
Win CE does not; I've gotten a request for a port to Windows CE.)
57+
58+
Chmlib apparently works on OS X, with some tweaks. In particular, disabling
59+
pread and io64 apparently works.
60+
61+
Finally, Andrew Hodgetts has ported to Solaris and IRIX:
62+
63+
On Monday, 7 Oct 2002, Andrew Hodgetts wrote:
64+
> Solaris(Sun):
65+
>
66+
> I used both SunProC and GCC on the solaris machines to compile. They
67+
> both worked ok.
68+
> However, both required -lsocket on the link line of the Makefile or you
69+
> recieve linking errors.
70+
>
71+
> I have this working on CPUs ranging from Sun4m (Sparc5) through to
72+
> UltraSparcIII (SunFireV880).
73+
>
74+
> Irix (SGI):
75+
>
76+
> I only testing with the MIPS compiler (not GCC). All worked ok - lots of
77+
> warning messages, but it always does that.
78+
79+
He further noted that:
80+
81+
> ... for NON GCC compilers, a little tweaking may be required, but nothing too
82+
> complex. ie SunProC doesn't understand -fPIC for library building. Irix
83+
> required -n32 (new 32bit libraries) etc. These are things that someone who
84+
> uses the OS and compiler should be used to dealing with.
85+
86+
-------
87+
CREDITS
88+
-------
89+
90+
* Stuart Caie: the LZX decompression code, and for granting permission to
91+
re-license under the LGPL.
92+
93+
* Sven Tantau: identification of a stack-overflow security flaw and a quick fix
94+
for the problem.
95+
96+
* iDEFENSE Labs: identification of a nasty stack-overflow security flaw
97+
98+
* Palasik Sandor: identification of a potential security flaw in lzx.c as well
99+
as a quick fix for the problem
100+
101+
* David Huseby: An excellent patch to the chm_enumerate functionality, relating
102+
to the "what" flags, which didn't work entirely correctly before
103+
104+
* Vadim Zeitlin: Configure script cleanup, including an important update to
105+
allow detection of platforms where pread64 doesn't work. (OS X)
106+
107+
* Vitaly V. Bursov: Compilation on x86-64.
108+
109+
* mc: A suggestion to add a "mkdir" to the install step.
110+
111+
* Stan Tobias: bugfixes and the added 'index page' feature of chm_http.
112+
113+
* Andrew Hodgetts: porting to Solaris and IRIX, as well as fixing some
114+
little-endian biases in the code.
115+
116+
* Rich Erwin: Windows CE support.
117+
118+
* Pabs: bug fixes and suggestions.
119+
120+
* Antony Dovgal: setting up autoconf/automake based build process.
121+
122+
* Ragnar Hojland Espinosa: patches to make chm_http more useful.
123+
124+
* Razvan Cojocaru: forwarding along information regarding building on OS X.
125+
126+
* Julien Lemoine: creating and maintaining the Debian package of chmlib.
127+
128+
* Anyone else I've forgotten. (?)
129+

0 commit comments

Comments
 (0)