1 diff a/src/rrd_graph.c /src/rrd_graph.c
2 --- a/src/rrd_graph.c
3 +++ b/src/rrd_graph.c
4 @@ -3958,6 +3958,7 @@ rrd_info_t *rrd_graph_v(
5 rrd_info_t *grinfo;
6 char *old_locale;
7 rrd_graph_init(&im);
8 + size_t graphfile_len;
9 /* a dummy surface so that we can measure text sizes for placements */
10 old_locale = setlocale(LC_NUMERIC, NULL);
11 setlocale(LC_NUMERIC, "C");
12 @@ -3975,7 +3976,9 @@ rrd_info_t *rrd_graph_v(
13 return NULL;
14 }
16 - if (strlen(argv[optind]) >= MAXPATH) {
17 + graphfile_len = strlen(argv[optind]);
18 +#ifdef MAXPATH
19 + if (graphfile_len >= MAXPATH) {
20 rrd_set_error("filename (including path) too long");
21 rrd_info_free(im.grinfo);
22 im_free(&im);
23 @@ -3984,6 +3987,16 @@ rrd_info_t *rrd_graph_v(
25 strncpy(im.graphfile, argv[optind], MAXPATH - 1);
26 im.graphfile[MAXPATH - 1] = '\0';
27 +#else
28 + im.graphfile = malloc(graphfile_len + 1);
29 + if (im.graphfile == NULL) {
30 + rrd_set_error("cannot allocate sufficient memory for filename length");
31 + rrd_info_free(im.grinfo);
32 + im_free(&im);
33 + return NULL;
34 + }
35 + strncpy(im.graphfile, argv[optind], graphfile_len + 1);
36 +#endif
38 if (strcmp(im.graphfile, "-") == 0) {
39 im.graphfile[0] = '\0';
40 --- a/src/rrd_graph.h
41 +++ b/src/rrd_graph.h
42 @@ -206,7 +206,11 @@ typedef struct image_desc_t {
44 /* configuration of graph */
46 +#ifdef MAXPATH
47 char graphfile[MAXPATH]; /* filename for graphic */
48 +#else
49 + char *graphfile; /* filename for graphic */
50 +#endif
51 long xsize, ysize; /* graph area size in pixels */
52 struct gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */
53 text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */
54 --- a/src/rrd_tool.c
55 +++ b/src/rrd_tool.c
56 @@ -576,7 +576,11 @@ int HandleInputLine(
57 printf("ERROR: invalid parameter count for pwd\n");
58 return (1);
59 }
60 +#ifdef __GLIBC__
61 + cwd = get_current_dir_name();
62 +#else
63 cwd = getcwd(NULL, MAXPATH);
64 +#endif
65 if (cwd == NULL) {
66 printf("ERROR: getcwd %s\n", rrd_strerror(errno));
67 return (1);