|
|
45e69e |
From b8682d868ddf7f741e93b791588af0932893f95c Mon Sep 17 00:00:00 2001
|
|
|
45e69e |
From: Pino Toscano <pino@kde.org>
|
|
|
45e69e |
Date: Mon, 16 Sep 2013 17:46:55 +0000
|
|
|
45e69e |
Subject: pdfseparate: improve the path building
|
|
|
45e69e |
|
|
|
45e69e |
Make use of snprintf to limit the output to the pathName buffer;
|
|
|
45e69e |
while I'm there, expand its size to 4096 (might help longer paths),
|
|
|
45e69e |
although a better fix would be dynamically allocate its length
|
|
|
45e69e |
(and/or using GooString, maybe).
|
|
|
45e69e |
---
|
|
|
45e69e |
(limited to 'utils/pdfseparate.cc')
|
|
|
45e69e |
|
|
|
45e69e |
diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc
|
|
|
45e69e |
index 35ae020..e41e547 100644
|
|
|
45e69e |
--- a/utils/pdfseparate.cc
|
|
|
45e69e |
+++ b/utils/pdfseparate.cc
|
|
|
45e69e |
@@ -44,7 +44,7 @@ static const ArgDesc argDesc[] = {
|
|
|
45e69e |
};
|
|
|
45e69e |
|
|
|
45e69e |
bool extractPages (const char *srcFileName, const char *destFileName) {
|
|
|
45e69e |
- char pathName[1024];
|
|
|
45e69e |
+ char pathName[4096];
|
|
|
45e69e |
GooString *gfileName = new GooString (srcFileName);
|
|
|
45e69e |
PDFDoc *doc = new PDFDoc (gfileName, NULL, NULL, NULL);
|
|
|
45e69e |
|
|
|
45e69e |
@@ -66,7 +66,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
|
|
|
45e69e |
return false;
|
|
|
45e69e |
}
|
|
|
45e69e |
for (int pageNo = firstPage; pageNo <= lastPage; pageNo++) {
|
|
|
45e69e |
- sprintf (pathName, destFileName, pageNo);
|
|
|
45e69e |
+ snprintf (pathName, sizeof (pathName) - 1, destFileName, pageNo);
|
|
|
45e69e |
GooString *gpageName = new GooString (pathName);
|
|
|
45e69e |
int errCode = doc->savePageAs(gpageName, pageNo);
|
|
|
45e69e |
if ( errCode != errNone) {
|
|
|
45e69e |
--
|
|
|
45e69e |
cgit v0.9.0.2-2-gbebe
|