On Wed, Aug 27, 2014 at 11:12:05PM +0200, Salvo 'LtWorf' Tomaselli wrote:
> 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());
> +             }

Oh. And as I read this again. I don't think this makes sense.
a) you should test for == PATH_MAX (as snprintf returns the number of
bytes printed, excluding the trailing '\0' and never prints more than 'n'
characters, in this case PATH_MAX.
b) all we print here is a number plus ".xml". If this number reaches more
than 255 digits (or 4091)... we have other problems.

So... let's split this patch and only take the first hunk, modified to
read 4096.

Do I still have permission to add your Signed-off-by? :-)

/D
_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to