Coin, Quoting Sebastian Harl <s...@tokkee.org>:
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.
Sorry, it was probably too late at night :-).
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.
Rights.
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__'.
Both are undefined on Hurd.I must have misread, as i was really sure it was always defined using one or the other. I've attached a fixed patch (but you probably corrected it already).
Thanks a lot for your comments and concern about the problem. -- Marc Dequènes (Duck)
Index: rrdtool-1.3.7/src/rrd_graph.c =================================================================== --- rrdtool-1.3.7.orig/src/rrd_graph.c 2009-05-28 00:30:47.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_graph.c 2009-05-28 21:59:54.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]); +#ifdef 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:30:48.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_graph.h 2009-05-28 22:06:53.000000000 +0200 @@ -196,7 +196,11 @@ /* configuration of graph */ +#ifdef MAXPATH char graphfile[MAXPATH]; /* filename for graphic */ +#else + char *graphfile; /* filename for graphic */ +#endif 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 21:58:47.000000000 +0200 +++ rrdtool-1.3.7/src/rrd_tool.c 2009-05-28 22:09:18.000000000 +0200 @@ -555,7 +555,11 @@ printf("ERROR: invalid parameter count for pwd\n"); return (1); } +#ifdef __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);
pgp5xst4wxsYq.pgp
Description: PGP Digital Signature