Hi Marc, On Thu, May 28, 2009 at 01:41:39AM +0200, Marc Dequ?nes (Duck) wrote: > Please consider applying this patch in your next upload and help us push > this fix upstream.
You forgot to actually attach the patch to your E-mail. I'm assuming you're talking about posixness_fix.diff which I've now attached to this E-mail. > Using PATH_MAX unconditionnaly is an important POSIX incompatibility; > The Hurd has no such limit, so it is undefined, so this fix relies on > dynamic allocations when it is not defined. The current version of your patch would require dynamic allocation on !Hurd as well, because you changed graphfile[MAXPATH] to *graphfile unconditionally, currently breaking the patch if MAXPATH is defined and non-zero. Does glibc on Hurd define PATH_MAX or MAXPATHLEN (which are used to define MAXPATH in RRDtool) at all? If not, please use '#ifdef MAXPATH' instead of '#if MAXPATH' to make it -Wundef save. Same for '#if __GLIBC__'. Thanks for pointing this out and your patch! Cheers, Sebastian -- Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/ Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin
Index: rrdtool-1.3.7/src/rrd_graph.c =================================================================== --- rrdtool-1.3.7.orig/src/rrd_graph.c 2009-05-28 00:07:39.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_graph.c 2009-05-28 00:09:14.000000000 +0200 @@ -3697,6 +3697,7 @@ image_desc_t im; rrd_info_t *grinfo; rrd_graph_init(&im); + size_t graphfile_len; /* a dummy surface so that we can measure text sizes for placements */ rrd_graph_options(argc, argv, &im); @@ -3713,7 +3714,9 @@ return NULL; } - if (strlen(argv[optind]) >= MAXPATH) { + graphfile_len = strlen(argv[optind]); +#if MAXPATH + if (graphfile_len >= MAXPATH) { rrd_set_error("filename (including path) too long"); rrd_info_free(im.grinfo); im_free(&im); @@ -3722,6 +3725,16 @@ strncpy(im.graphfile, argv[optind], MAXPATH - 1); im.graphfile[MAXPATH - 1] = '\0'; +#else + im.graphfile = malloc(graphfile_len + 1); + if (im.graphfile == NULL) { + rrd_set_error("cannot allocate sufficient memory for filename length"); + rrd_info_free(im.grinfo); + im_free(&im); + return NULL; + } + strncpy(im.graphfile, argv[optind], graphfile_len + 1); +#endif if (strcmp(im.graphfile, "-") == 0) { im.graphfile[0] = '\0'; Index: rrdtool-1.3.7/src/rrd_graph.h =================================================================== --- rrdtool-1.3.7.orig/src/rrd_graph.h 2009-05-28 00:07:39.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_graph.h 2009-05-28 00:09:14.000000000 +0200 @@ -196,7 +196,7 @@ /* configuration of graph */ - char graphfile[MAXPATH]; /* filename for graphic */ + char *graphfile; /* filename for graphic */ long xsize, ysize; /* graph area size in pixels */ struct gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */ text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */ Index: rrdtool-1.3.7/src/rrd_tool.c =================================================================== --- rrdtool-1.3.7.orig/src/rrd_tool.c 2009-05-28 00:09:13.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_tool.c 2009-05-28 00:09:14.000000000 +0200 @@ -16,6 +16,8 @@ #include <unistd.h> +#include <unistd.h> + #include "rrd_tool.h" #include "rrd_xport.h" #include "rrd_i18n.h" @@ -555,7 +557,11 @@ printf("ERROR: invalid parameter count for pwd\n"); return (1); } +#if __GLIBC__ + cwd = get_current_dir_name(); +#else cwd = getcwd(NULL, MAXPATH); +#endif if (cwd == NULL) { printf("ERROR: getcwd %s\n", rrd_strerror(errno)); return (1);
signature.asc
Description: Digital signature