[PATCH] Define PATH_MAX if it's not defined
Salvo 'LtWorf' Tomaselli
tiposchi at tiscali.it
Wed Aug 27 14:12:05 PDT 2014
Fixes FTBFS on Hurd.
Also makes sure that if the file is truncated, there is a way of
knowing what is happening.
---
qt-ui/subsurfacewebservices.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index c3661e0..4111f8c 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -29,6 +29,10 @@
#include <QUrlQuery>
#endif
+#ifndef PATH_MAX
+#define PATH_MAX 260
+#endif
+
struct dive_table gps_location_table;
static bool merge_locations_into_dives(void);
@@ -194,7 +198,9 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile,
/*
* Save the XML document into a zip file.
*/
- snprintf(filename, PATH_MAX, "%d.xml", i + 1);
+ if (snprintf(filename, PATH_MAX, "%d.xml", i + 1)>= PATH_MAX) {
+ report_error(tr("long path was truncated").toUtf8());
+ }
s = zip_source_buffer(zip, membuf, streamsize, 1);
if (s) {
int64_t ret = zip_add(zip, filename, s);
--
2.1.0
More information about the subsurface
mailing list