Build DAHDi Tools from Source on CentOS 8.2

Trying to get dahdi-tools to compile on CentOS 8.2 (Kernel 4.18.0-193.28.1.el8_2.x86_64) using official github, sruffell’s copy, or downloaded/release tar… I’m getting the following errors during ‘make’; is there anything I can try?

  CC       dahdi_cfg.o
dahdi_cfg.c: In function ‘are_all_spans_assigned’:
dahdi_cfg.c:153:7: warning: ‘/span_count’ directive output may be truncated writing 11 bytes into a region of size between 0 and 1023 [-Wformat-truncation=]
    "%s/span_count", device_path);
       ^~~~~~~~~~~
dahdi_cfg.c:152:2: note: ‘snprintf’ output between 12 and 1035 bytes into a destination of size 1023
  snprintf(attribute, sizeof(attribute) - 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "%s/span_count", device_path);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CCLD     dahdi_cfg

...

  CC       dahdi_tool-dahdi_tool.o
dahdi_tool.c: In function ‘sel_callback’:
dahdi_tool.c:167:40: warning: ‘            F10=Quit’ directive output may be truncated writing 20 bytes into a region of size between 1 and 197 [-Wformat-truncation=]
   snprintf(info2, sizeof(info2), "%-59s            F10=Quit", info);
                                        ^~~~~~~~~~~~~~~~~~~~
dahdi_tool.c:167:3: note: ‘snprintf’ output between 80 and 276 bytes into a destination of size 256
   snprintf(info2, sizeof(info2), "%-59s            F10=Quit", info);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dahdi_tool.c:163:40: warning: ‘ F1=Details F10=Quit’ directive output may be truncated writing 20 bytes into a region of size between 1 and 197 [-Wformat-truncation=]
   snprintf(info2, sizeof(info2), "%-59s F1=Details F10=Quit", info);
                                        ^~~~~~~~~~~~~~~~~~~~
dahdi_tool.c:163:3: note: ‘snprintf’ output between 80 and 276 bytes into a destination of size 256
   snprintf(info2, sizeof(info2), "%-59s F1=Details F10=Quit", info);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CCLD     dahdi_tool

Those might be “warning” messages and not “error” ?

Correct, they are warnings… ‘output may be truncated’ is concerning, any ideas?

Zealous compiler developers should be celebrated, and those warnings fixed, but it is not something that you probably need to worry about day-to-day, no.

These are formatted output requests. The compiler is using special knowledge about the specific sub-routines being used and has calculated how long the output string could be if the string in info was the maximum length string that would fit in info, and has compared that with the amount of memory provided to take the expanded string. The former is longer than the latter. However, it is possible that the programmer knew that the worst case combination of values isn’t actually possible in real life.

Given the -59, and without looking at the code, it may be that a standard length scratch buffer is being used, but the particular value being output is known to be only 59 bytes long, at most.

As this is quite a sophisticated check, which assumes you are using a specific standard subroutine, rather than something that just has the same name, it may be a new feature of the compiler. If the compilation fails because of it, it may be because the compilation options are set not to allow warning, in which case removing or refining that option would allow it to complete.

The subroutine used size checks the output buffer at run time, so you won’t get a buffer overrun security failure. It looks like this output is for human consumption, so the worst you will get is truncated output to the human.

1 Like

Thank you both for the explanation and reassurance; it is appreciated!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.