Code

8e8941d02e1eaf5e1d03da41991b503b31ebdcc6
[pkg-rrdtool.git] / debian / patches / bts530814-hurd
1 diff a/src/rrd_graph.c /src/rrd_graph.c
2 --- a/src/rrd_graph.c
3 +++ b/src/rrd_graph.c
4 @@ -3697,6 +3697,7 @@
5      image_desc_t im;
6      rrd_info_t *grinfo;
7      rrd_graph_init(&im);
8 +    size_t graphfile_len;
9      /* a dummy surface so that we can measure text sizes for placements */
10      
11      rrd_graph_options(argc, argv, &im);
12 @@ -3713,7 +3714,9 @@
13          return NULL;
14      }
15  
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 @@ -3722,6 +3725,16 @@
24  
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
37  
38      if (strcmp(im.graphfile, "-") == 0) {
39          im.graphfile[0] = '\0';
40 diff a/src/rrd_graph.h b/src/rrd_graph.h
41 --- a/src/rrd_graph.h
42 +++ b/src/rrd_graph.h
43 @@ -196,7 +196,11 @@
44  
45      /* configuration of graph */
46  
47 +#ifdef MAXPATH
48      char      graphfile[MAXPATH];   /* filename for graphic */
49 +#else
50 +    char      *graphfile;   /* filename for graphic */
51 +#endif
52      long      xsize, ysize; /* graph area size in pixels */
53      struct gfx_color_t graph_col[__GRC_END__];  /* real colors for the graph */
54      text_prop_t text_prop[TEXT_PROP_LAST];  /* text properties */
55 diff a/src/rrd_tool.c b/src/rrd_tool.c
56 --- a/src/rrd_tool.c
57 +++ b/src/rrd_tool.c
58 @@ -555,7 +555,11 @@
59                  printf("ERROR: invalid parameter count for pwd\n");
60                  return (1);
61              }
62 +#ifdef __GLIBC__
63 +            cwd = get_current_dir_name();
64 +#else
65              cwd = getcwd(NULL, MAXPATH);
66 +#endif
67              if (cwd == NULL) {
68                  printf("ERROR: getcwd %s\n", rrd_strerror(errno));
69                  return (1);