diff a/src/rrd_graph.c /src/rrd_graph.c --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -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'; diff a/src/rrd_graph.h b/src/rrd_graph.h --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -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 */ diff a/src/rrd_tool.c b/src/rrd_tool.c --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -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);