[poppler] Branch 'poppler-0.24' - utils/pdfseparate.cc

Pino Toscano pino at kemper.freedesktop.org
Mon Sep 16 10:49:57 PDT 2013


 utils/pdfseparate.cc |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b8682d868ddf7f741e93b791588af0932893f95c
Author: Pino Toscano <pino at kde.org>
Date:   Mon Sep 16 19:46:55 2013 +0200

    pdfseparate: improve the path building
    
    Make use of snprintf to limit the output to the pathName buffer;
    while I'm there, expand its size to 4096 (might help longer paths),
    although a better fix would be dynamically allocate its length
    (and/or using GooString, maybe).

diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc
index 35ae020..e41e547 100644
--- a/utils/pdfseparate.cc
+++ b/utils/pdfseparate.cc
@@ -44,7 +44,7 @@ static const ArgDesc argDesc[] = {
 };
 
 bool extractPages (const char *srcFileName, const char *destFileName) {
-  char pathName[1024];
+  char pathName[4096];
   GooString *gfileName = new GooString (srcFileName);
   PDFDoc *doc = new PDFDoc (gfileName, NULL, NULL, NULL);
 
@@ -66,7 +66,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
     return false;
   }
   for (int pageNo = firstPage; pageNo <= lastPage; pageNo++) {
-    sprintf (pathName, destFileName, pageNo);
+    snprintf (pathName, sizeof (pathName) - 1, destFileName, pageNo);
     GooString *gpageName = new GooString (pathName);
     int errCode = doc->savePageAs(gpageName, pageNo);
     if ( errCode != errNone) {


More information about the poppler mailing list