diff -ru poppler-0.6.3/fofi/FoFiBase.cc poppler-0.6.3-new/fofi/FoFiBase.cc --- poppler-0.6.3/fofi/FoFiBase.cc 2007-11-04 23:10:59.000000000 +0000 +++ poppler-0.6.3-new/fofi/FoFiBase.cc 2008-01-18 17:36:32.000000000 +0000 @@ -12,7 +12,10 @@ #pragma implementation #endif +#include +#include #include +#include #include "goo/gmem.h" #include "FoFiBase.h" @@ -40,9 +43,19 @@ if (!(f = fopen(fileName, "rb"))) { return NULL; } - fseek(f, 0, SEEK_END); + int error = fseek(f, 0, SEEK_END); + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } n = (int)ftell(f); - fseek(f, 0, SEEK_SET); + error = fseek(f, 0, SEEK_SET); + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } buf = (char *)gmalloc(n); if ((int)fread(buf, 1, n, f) != n) { gfree(buf); Only in poppler-0.6.3/glib: poppler-enums.c Only in poppler-0.6.3/glib: poppler-enums.h Only in poppler-0.6.3/glib: poppler-features.h diff -ru poppler-0.6.3/poppler/GfxFont.cc poppler-0.6.3-new/poppler/GfxFont.cc --- poppler-0.6.3/poppler/GfxFont.cc 2007-11-04 23:11:04.000000000 +0000 +++ poppler-0.6.3-new/poppler/GfxFont.cc 2008-01-18 17:35:18.000000000 +0000 @@ -12,9 +12,12 @@ #pragma implementation #endif +#include +#include #include #include #include +#include #include #include "goo/gmem.h" #include "Error.h" @@ -404,9 +407,19 @@ error(-1, "External font file '%s' vanished", extFontFile->getCString()); return NULL; } - fseek(f, 0, SEEK_END); + int fseek_error = fseek(f, 0, SEEK_END); + if (fseek_error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } *len = (int)ftell(f); - fseek(f, 0, SEEK_SET); + fseek_error = fseek(f, 0, SEEK_SET); + if (fseek_error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } buf = (char *)gmalloc(*len); if ((int)fread(buf, 1, *len, f) != *len) { error(-1, "Error reading external font file '%s'", Only in poppler-0.6.3/poppler: poppler-config.h diff -ru poppler-0.6.3/poppler/Stream.cc poppler-0.6.3-new/poppler/Stream.cc --- poppler-0.6.3/poppler/Stream.cc 2007-11-08 22:13:50.000000000 +0000 +++ poppler-0.6.3-new/poppler/Stream.cc 2008-01-18 17:36:11.000000000 +0000 @@ -12,6 +12,8 @@ #pragma implementation #endif +#include +#include #include #include #include @@ -19,6 +21,7 @@ #ifndef WIN32 #include #endif +#include #include #include #include "goo/gmem.h" @@ -603,16 +606,22 @@ } void FileStream::reset() { + int error; #if HAVE_FSEEKO savePos = (Guint)ftello(f); - fseeko(f, start, SEEK_SET); + error = fseeko(f, start, SEEK_SET); #elif HAVE_FSEEK64 savePos = (Guint)ftell64(f); - fseek64(f, start, SEEK_SET); + error = fseek64(f, start, SEEK_SET); #else savePos = (Guint)ftell(f); - fseek(f, start, SEEK_SET); + error = fseek(f, start, SEEK_SET); #endif + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } saved = gTrue; bufPtr = bufEnd = buf; bufPos = start; @@ -620,13 +629,19 @@ void FileStream::close() { if (saved) { + int error; #if HAVE_FSEEKO - fseeko(f, savePos, SEEK_SET); + error = fseeko(f, savePos, SEEK_SET); #elif HAVE_FSEEK64 - fseek64(f, savePos, SEEK_SET); + error = fseek64(f, savePos, SEEK_SET); #else - fseek(f, savePos, SEEK_SET); + error = fseek(f, savePos, SEEK_SET); #endif + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } saved = gFalse; } } @@ -656,39 +671,67 @@ Guint size; if (dir >= 0) { + int error; #if HAVE_FSEEKO - fseeko(f, pos, SEEK_SET); + error = fseeko(f, pos, SEEK_SET); #elif HAVE_FSEEK64 - fseek64(f, pos, SEEK_SET); + error = fseek64(f, pos, SEEK_SET); #else - fseek(f, pos, SEEK_SET); + error = fseek(f, pos, SEEK_SET); #endif + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } bufPos = pos; } else { + int error; +#if HAVE_FSEEKO + error = fseeko(f, 0, SEEK_END); +#elif HAVE_FSEEK64 + error = fseek64(f, 0, SEEK_END); +#else + error = fseek(f, 0, SEEK_END); +#endif + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } + #if HAVE_FSEEKO - fseeko(f, 0, SEEK_END); size = (Guint)ftello(f); #elif HAVE_FSEEK64 - fseek64(f, 0, SEEK_END); size = (Guint)ftell64(f); #else - fseek(f, 0, SEEK_END); size = (Guint)ftell(f); #endif + if (pos > size) pos = (Guint)size; #ifdef __CYGWIN32__ //~ work around a bug in cygwin's implementation of fseek rewind(f); #endif + +#if HAVE_FSEEKO + error = fseeko(f, -(int)pos, SEEK_END); +#elif HAVE_FSEEK64 + error = fseek64(f, -(int)pos, SEEK_END); +#else + error = fseek(f, -(int)pos, SEEK_END); +#endif + if (error) { + std::string s(strerror(errno)); + std::runtime_error e(s); + throw e; + } #if HAVE_FSEEKO - fseeko(f, -(int)pos, SEEK_END); bufPos = (Guint)ftello(f); #elif HAVE_FSEEK64 - fseek64(f, -(int)pos, SEEK_END); bufPos = (Guint)ftell64(f); #else - fseek(f, -(int)pos, SEEK_END); bufPos = (Guint)ftell(f); #endif } diff -ru poppler-0.6.3/utils/pdfinfo.cc poppler-0.6.3-new/utils/pdfinfo.cc --- poppler-0.6.3/utils/pdfinfo.cc 2007-11-04 23:11:29.000000000 +0000 +++ poppler-0.6.3-new/utils/pdfinfo.cc 2008-01-18 17:25:22.000000000 +0000 @@ -257,15 +257,16 @@ f = fopen(fileName->getCString(), "rb"); #endif if (f) { + // If it's not seekable we cannot report the size. #if HAVE_FSEEKO - fseeko(f, 0, SEEK_END); - printf("File size: %u bytes\n", (Guint)ftello(f)); + if (fseeko(f, 0, SEEK_END) == 0) + printf("File size: %u bytes\n", (Guint)ftello(f)); #elif HAVE_FSEEK64 - fseek64(f, 0, SEEK_END); - printf("File size: %u bytes\n", (Guint)ftell64(f)); + if (fseek64(f, 0, SEEK_END) == 0) + printf("File size: %u bytes\n", (Guint)ftell64(f)); #else - fseek(f, 0, SEEK_END); - printf("File size: %d bytes\n", (int)ftell(f)); + if (fseek(f, 0, SEEK_END) == 0) + printf("File size: %d bytes\n", (int)ftell(f)); #endif fclose(f); }