From b8682d868ddf7f741e93b791588af0932893f95c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 16 Sep 2013 17:46:55 +0000 Subject: 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). --- (limited to 'utils/pdfseparate.cc') 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) { -- cgit v0.9.0.2-2-gbebe