diff a/src/rrd_graph.c /src/rrd_graph.c --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -3958,6 +3958,7 @@ rrd_info_t *rrd_graph_v( rrd_info_t *grinfo; char *old_locale; rrd_graph_init(&im); + size_t graphfile_len; /* a dummy surface so that we can measure text sizes for placements */ old_locale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); @@ -3975,7 +3976,9 @@ rrd_info_t *rrd_graph_v( 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); @@ -3984,6 +3987,16 @@ rrd_info_t *rrd_graph_v( 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'; --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -206,7 +206,11 @@ typedef struct image_desc_t { /* 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 */ --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -576,7 +576,11 @@ int HandleInputLine( 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);