Commit 6415a476 authored by Christophe Devriese's avatar Christophe Devriese
Browse files

xpdf update to version 2.02pl1

this fixes the security bug people have been complaining about

svn path=/trunk/kdegraphics/kpdf/; revision=243811
parent a29ed35a
......@@ -2,7 +2,7 @@
//
// GHash.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// GHash.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// GList.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// GList.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -4,7 +4,7 @@
//
// Simple variable-length string type.
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -4,7 +4,7 @@
//
// Simple variable-length string type.
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -4,7 +4,7 @@
//
// Miscellaneous file and directory name manipulation.
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -108,7 +108,7 @@ GString *getCurrentDir() {
return new GString();
}
GString *appendToPath(GString *path, const char *fileName) {
GString *appendToPath(GString *path, char *fileName) {
#if defined(VMS)
//---------- VMS ----------
//~ this should handle everything necessary for file
......@@ -443,13 +443,10 @@ time_t getModTime(char *fileName) {
#endif
}
GBool openTempFile(GString **name, FILE **f,
const char *mode, const char *ext) {
GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
#if defined(WIN32)
//---------- Win32 ----------
char *s;
char buf[_MAX_PATH];
char *fp;
if (!(s = _tempnam(getenv("TEMP"), NULL))) {
return gFalse;
......@@ -647,10 +644,8 @@ GDir::~GDir() {
}
GDirEntry *GDir::getNextEntry() {
struct dirent *ent;
GDirEntry *e;
e = NULL;
#if defined(WIN32)
e = new GDirEntry(path->getCString(), ffd.cFileName, doStat);
if (hnd && !FindNextFile(hnd, &ffd)) {
......@@ -659,24 +654,34 @@ GDirEntry *GDir::getNextEntry() {
}
#elif defined(ACORN)
#elif defined(MACOS)
#else
#elif defined(VMS)
struct dirent *ent;
e = NULL;
if (dir) {
#ifdef VMS
if (needParent) {
e = new GDirEntry(path->getCString(), "-", doStat);
needParent = gFalse;
return e;
}
#endif
ent = readdir(dir);
#ifndef VMS
if (ent && !strcmp(ent->d_name, "."))
if (ent) {
e = new GDirEntry(path->getCString(), ent->d_name, doStat);
}
}
#else
struct dirent *ent;
e = NULL;
if (dir) {
ent = readdir(dir);
if (ent && !strcmp(ent->d_name, ".")) {
ent = readdir(dir);
#endif
if (ent)
}
if (ent) {
e = new GDirEntry(path->getCString(), ent->d_name, doStat);
}
}
#endif
return e;
}
......
......@@ -4,7 +4,7 @@
//
// Miscellaneous file and directory name manipulation.
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -60,7 +60,7 @@ extern GString *getCurrentDir();
// Append a file name to a path string. <path> may be an empty
// string, denoting the current directory). Returns <path>.
extern GString *appendToPath(GString *path, const char *fileName);
extern GString *appendToPath(GString *path, char *fileName);
// Grab the path from the front of the file name. If there is no
// directory component in <fileName>, returns an empty string.
......@@ -83,8 +83,7 @@ extern time_t getModTime(char *fileName);
// should be done to the returned file pointer; the file may be
// reopened later for reading, but not for writing. The <mode> string
// should be "w" or "wb". Returns true on success.
extern GBool openTempFile(GString **name, FILE **f,
const char *mode, const char *ext);
extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
// Execute <command>. Returns true on success.
extern GBool executeCommand(char *cmd);
......
......@@ -3,7 +3,7 @@
*
* Memory routines with out-of-memory checking.
*
* Copyright 1996-2002 Glyph & Cog, LLC
* Copyright 1996-2003 Glyph & Cog, LLC
*/
#include <aconf.h>
......@@ -195,7 +195,7 @@ void gMemReport(FILE *f) {
}
#endif
char *copyString(const char *s) {
char *copyString(char *s) {
char *s1;
s1 = (char *)gmalloc(strlen(s) + 1);
......
......@@ -3,7 +3,7 @@
*
* Memory routines with out-of-memory checking.
*
* Copyright 1996-2002 Glyph & Cog, LLC
* Copyright 1996-2003 Glyph & Cog, LLC
*/
#ifndef GMEM_H
......@@ -44,7 +44,7 @@ extern void gMemReport(FILE *f);
/*
* Allocate memory and copy a string into it.
*/
extern char *copyString(const char *s);
extern char *copyString(char *s);
#ifdef __cplusplus
}
......
......@@ -4,7 +4,7 @@
//
// Use gmalloc/gfree for C++ new/delete operators.
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -3,7 +3,7 @@
*
* Some useful simple types.
*
* Copyright 1996-2002 Glyph & Cog, LLC
* Copyright 1996-2003 Glyph & Cog, LLC
*/
#ifndef GTYPES_H
......
......@@ -3,7 +3,7 @@
*
* Command line argument parser.
*
* Copyright 1996-2002 Glyph & Cog, LLC
* Copyright 1996-2003 Glyph & Cog, LLC
*/
#include <stdio.h>
......
......@@ -3,7 +3,7 @@
*
* Command line argument parser.
*
* Copyright 1996-2002 Glyph & Cog, LLC
* Copyright 1996-2003 Glyph & Cog, LLC
*/
#ifndef PARSEARGS_H
......
......@@ -94,7 +94,7 @@ static QOutFontSubst qStdFonts [] = {
{ 0, 0, false, false, QFont::AnyStyle }
};
QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 )
QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t /* m11 */, fp_t m12, fp_t m21, fp_t m22 )
{
static QDict<QOutFontSubst> stdfonts;
......@@ -216,7 +216,7 @@ void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
void QOutputDev::endPage ( )
{
m_text-> coalesce ( );
m_text-> coalesce ( true );
delete m_painter;
m_painter = 0;
......@@ -605,12 +605,12 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
void QOutputDev::beginString ( GfxState *state, GString */*s*/ )
{
m_text-> beginString ( state, state->getCurX(), state->getCurY() );
m_text-> beginWord ( state, state->getCurX(), state->getCurY() );
}
void QOutputDev::endString ( GfxState */*state*/ )
{
m_text-> endString ( );
m_text-> endWord ( );
}
void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
......@@ -620,7 +620,7 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
fp_t x1, y1, dx1, dy1;
if ( uLen > 0 )
m_text-> addChar ( state, x, y, dx, dy, u, uLen );
m_text-> addChar ( state, x, y, dx, dy, code, u, uLen );
// check for invisible text -- this is used by Acrobat Capture
if (( state-> getRender ( ) & 3 ) == 3 ) {
......
......@@ -201,7 +201,7 @@ void QOutputDevPixmap::startPage ( int /*pageNum*/, GfxState *state )
void QOutputDevPixmap::endPage ( )
{
m_text-> coalesce ( );
m_text-> coalesce ( true );
delete m_painter;
m_painter = 0;
......@@ -590,12 +590,12 @@ int QOutputDevPixmap::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPo
void QOutputDevPixmap::beginString ( GfxState *state, GString */*s*/ )
{
m_text-> beginString ( state, state->getCurX(), state->getCurY() );
m_text-> beginWord ( state, state->getCurX(), state->getCurY() );
}
void QOutputDevPixmap::endString ( GfxState */*state*/ )
{
m_text-> endString ( );
m_text-> endWord ( );
}
void QOutputDevPixmap::drawChar ( GfxState *state, fp_t x, fp_t y,
......@@ -605,7 +605,7 @@ void QOutputDevPixmap::drawChar ( GfxState *state, fp_t x, fp_t y,
fp_t x1, y1, dx1, dy1;
if ( uLen > 0 )
m_text-> addChar ( state, x, y, dx, dy, u, uLen );
m_text-> addChar ( state, x, y, dx, dy, code, u, uLen );
// check for invisible text -- this is used by Acrobat Capture
if (( state-> getRender ( ) & 3 ) == 3 ) {
......
......@@ -192,7 +192,7 @@ Part::displayPage(int pageNumber, float /*zoomFactor*/)
break;
}
const float ppp = basePpp * m_zoomFactor; // pixels per point
//const float ppp = basePpp * m_zoomFactor; // pixels per point
// m_doc->displayPage(m_outputDev, pageNumber, int(m_zoomFactor * ppp * 72.0), 0, true);
......
......@@ -2,7 +2,7 @@
//
// Annot.cc
//
// Copyright 2000-2002 Glyph & Cog, LLC
// Copyright 2000-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// Annot.h
//
// Copyright 2000-2002 Glyph & Cog, LLC
// Copyright 2000-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// Array.cc
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -12,6 +12,7 @@
#pragma implementation
#endif
#include <stdlib.h>
#include <stddef.h>
#include "gmem.h"
#include "Object.h"
......@@ -46,9 +47,23 @@ void Array::add(Object *elem) {
}
Object *Array::get(int i, Object *obj) {
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
#else
return obj->initNull();
#endif
}
return elems[i].fetch(xref, obj);
}
Object *Array::getNF(int i, Object *obj) {
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
#else
return obj->initNull();
#endif
}
return elems[i].copy(obj);
}
......@@ -2,7 +2,7 @@
//
// Array.h
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// BuiltinFont.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -53,8 +53,8 @@ GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) {
return gFalse;
}
int BuiltinFontWidths::hash(const char *name) {
const char *p;
int BuiltinFontWidths::hash(char *name) {
char *p;
unsigned int h;
h = 0;
......
......@@ -2,7 +2,7 @@
//
// BuiltinFont.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -23,8 +23,8 @@ class BuiltinFontWidths;
//------------------------------------------------------------------------
struct BuiltinFont {
const char *name;
const char **defaultBaseEnc;
char *name;
char **defaultBaseEnc;
short ascent;
short descent;
short bbox[4];
......@@ -34,7 +34,7 @@ struct BuiltinFont {
//------------------------------------------------------------------------
struct BuiltinFontWidth {
const char *name;
char *name;
Gushort width;
BuiltinFontWidth *next;
};
......@@ -48,7 +48,7 @@ public:
private:
int hash(const char *name);
int hash(char *name);
BuiltinFontWidth **tab;
int size;
......
......@@ -2,7 +2,7 @@
//
// BuiltinFontTables.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// BuiltinFontTables.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// CMap.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// CMap.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// Catalog.cc
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// Catalog.h
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// CharCodeToUnicode.cc
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -224,7 +224,7 @@ void CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
map[i] = 0;
}
}
if (n3 == 6) {
if (n3 <= 6) {
if (sscanf(tok3 + 1, "%x", &u) != 1) {
error(-1, "Illegal entry in bfrange block in ToUnicode CMap");
continue;
......
......@@ -4,7 +4,7 @@
//
// Mapping from character codes to Unicode.
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,7 +2,7 @@
//
// CharTypes.h
//
// Copyright 2001-2002 Glyph & Cog, LLC
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
......
......@@ -2,14 +2,14 @@
//
// CompactFontTables.h
//
// Copyright 1999-2002 Glyph & Cog, LLC
// Copyright 1999-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef COMPACTFONTINFO_H
#define COMPACTFONTINFO_H
static const char *type1CStdStrings[391] = {
static char *type1CStdStrings[391] = {
".notdef",
"space",
"exclam",
......
......@@ -2,7 +2,7 @@
//
// Decrypt.cc
//
// Copyright 1996-2002 Glyph & Cog, LLC
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
......@@ -21,8 +21,8 @@ static void md5(Guchar *msg, int msgLen, Guchar *digest);
static Guchar passwordPad[32] = {
0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41,
0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08,
0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08,
0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a
};
......@@ -92,9 +92,9 @@ GBool Decrypt::makeFileKey(int encVersion, int encRevision, int keyLength,
}
}
if (encRevision == 2) {
rc4InitKey(test, keyLength, fState);
fx = fy = 0;
for (i = 0; i < 32; ++i) {
rc4InitKey(test, keyLength, fState);
fx = fy = 0;
for (i = 0; i < 32; ++i) {
test2[i] = rc4DecryptByte(fState, &fx, &fy, ownerKey->getChar(i));
}
} else {
......@@ -125,7 +125,7 @@ GBool Decrypt::makeFileKey(int encVersion, int encRevision, int keyLength,
permissions, fileID, userPassword, fileKey);
}
GBool Decrypt::makeFileKey2(int /* encVersion */, int encRevision, int keyLength,
GBool Decrypt::makeFileKey2(int encVersion, int encRevision, int keyLength,
GString *ownerKey, GString *userKey,
int permissions, GString *fileID,
GString *userPassword, Guchar *fileKey) {
......@@ -382,20 +382,20 @@ static void md5(Guchar *msg, int msgLen, Guchar *digest) {
}
// break digest into bytes