Latest ESP-IDF compilation error

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

Re: Latest ESP-IDF compilation error

Postby tionebrr » Mon Aug 17, 2020 3:50 pm

I have the same issue. I am using the docker esp-idf v4.2.

Code: Select all

../components/webserver/webserver.c:57:5: error: 'strncpy' output truncated before terminating nul copying 8 bytes from a string of the same length [-Werror=stringop-truncation]
     strncpy(filename, filepath_prefix, strlen(filepath_prefix));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is the relevant bit of code:

Code: Select all

    const char *filepath_prefix = "/sdcard/www/";
    char *filename = NULL;
    size_t filename_len = httpd_req_get_url_query_len(req);

    if (filename_len == 0) {
        const char * resp_str = "Please specify a filename. eg. file?somefile.txt";
        httpd_resp_send(req, resp_str, strlen(resp_str));
        return ESP_OK;
    }
    filename = malloc(strlen(filepath_prefix) + filename_len + 1); // extra 1 byte for null termination
    strncpy(filename, filepath_prefix, strlen(filepath_prefix));
Has anyone found a clean workaround ?

tolkienfan
Posts: 1
Joined: Mon May 31, 2021 12:00 am

Re: Latest ESP-IDF compilation error

Postby tolkienfan » Mon May 31, 2021 12:07 am

This code is definitely incorrect. strncpy will not write the nul terminator since it's beyond the size passed as an argument.

expresspotato
Posts: 24
Joined: Fri May 28, 2021 1:58 pm

Re: Latest ESP-IDF compilation error

Postby expresspotato » Sun Jul 11, 2021 7:54 pm

I'm still having this issue on v4.3. Select Optimize for Performance and you cannot build.

Code: Select all

-- Build files have been written to: /home/kevin/workspace/liberty/build
[895/1371] Building C object esp-idf/bt/CMakeFiles/__idf_bt.dir/host/bluedroid/stack/l2cap/l2c_ble.c.obj
/home/kevin/esp-idf/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c: In function 'l2c_ble_link_adjust_allocation':
/home/kevin/esp-idf/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c:1014:21: warning: unused variable 'yy' [-Wunused-variable]
     UINT16      qq, yy = 0, qq_remainder;
                     ^~
[901/1371] Building C object esp-idf/bt/CMakeFiles/__idf_bt.dir/host/bluedroid/stack/l2cap/l2c_link.c.obj
/home/kevin/esp-idf/components/bt/host/bluedroid/stack/l2cap/l2c_link.c: In function 'l2c_link_adjust_allocation':
/home/kevin/esp-idf/components/bt/host/bluedroid/stack/l2cap/l2c_link.c:721:21: warning: unused variable 'yy' [-Wunused-variable]
     UINT16      qq, yy = 0, qq_remainder;
                     ^~
[1281/1371] Building C object esp-idf/esp_peripherals/CMakeFiles/__idf_esp_peripherals.dir/periph_console.c.obj
/home/kevin/esp-adf/components/esp_peripherals/periph_console.c: In function '_console_init':
/home/kevin/esp-adf/components/esp_peripherals/periph_console.c:254:5: warning: 'esp_vfs_dev_uart_set_rx_line_endings' is deprecated [-Wdeprecated-declarations]
     esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/kevin/esp-adf/components/esp_peripherals/periph_console.c:29:
/home/kevin/esp-idf/components/vfs/include/esp_vfs_dev.h:45:6: note: declared here
 void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode) __attribute__((deprecated));
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kevin/esp-adf/components/esp_peripherals/periph_console.c:256:5: warning: 'esp_vfs_dev_uart_set_tx_line_endings' is deprecated [-Wdeprecated-declarations]
     esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/kevin/esp-adf/components/esp_peripherals/periph_console.c:29:
/home/kevin/esp-idf/components/vfs/include/esp_vfs_dev.h:61:6: note: declared here
 void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode) __attribute__((deprecated));
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1290/1371] Building C object esp-idf/esp_peripherals/CMakeFiles/__idf_esp_peripherals.dir/periph_ws2812.c.obj
/home/kevin/esp-adf/components/esp_peripherals/periph_ws2812.c: In function 'ws2812_init_rmt_channel':
/home/kevin/esp-adf/components/esp_peripherals/periph_ws2812.c:111:5: warning: 'rmt_set_intr_enable_mask' is deprecated: interrupt should be handled by driver [-Wdeprecated-declarations]
     rmt_set_intr_enable_mask(BIT(0) | BIT(24));
     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/kevin/esp-adf/components/esp_peripherals/periph_ws2812.c:29:
/home/kevin/esp-idf/components/driver/include/driver/rmt.h:893:6: note: declared here
 void rmt_set_intr_enable_mask(uint32_t mask)
      ^~~~~~~~~~~~~~~~~~~~~~~~
[1295/1371] Building C object esp-idf/battery_service/CMakeFiles/__idf_battery_service.dir/battery_service.c.obj
/home/kevin/esp-adf/components/battery_service/battery_service.c: In function 'battery_task':
/home/kevin/esp-adf/components/battery_service/battery_service.c:122:38: warning: this statement may fall through [-Wimplicit-fallthrough=]
                     service->running = false;
                                      ^
/home/kevin/esp-adf/components/battery_service/battery_service.c:124:17: note: here
                 case BATTERY_SERVICE_STOP: {
                 ^~~~
[1304/1371] Building C object esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/dram_list.c.obj
FAILED: esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/dram_list.c.obj 
/home/kevin/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DADF_VER=\"27d8bd8-dirty\" -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -Iconfig -I/home/kevin/esp-adf/components/playlist/include -I/home/kevin/esp-idf/components/newlib/platform_include -I/home/kevin/esp-idf/components/freertos/include -I/home/kevin/esp-idf/components/freertos/port/xtensa/include -I/home/kevin/esp-idf/components/esp_hw_support/include -I/home/kevin/esp-idf/components/esp_hw_support/port/esp32/. -I/home/kevin/esp-idf/components/heap/include -I/home/kevin/esp-idf/components/log/include -I/home/kevin/esp-idf/components/lwip/include/apps -I/home/kevin/esp-idf/components/lwip/include/apps/sntp -I/home/kevin/esp-idf/components/lwip/lwip/src/include -I/home/kevin/esp-idf/components/lwip/port/esp32/include -I/home/kevin/esp-idf/components/lwip/port/esp32/include/arch -I/home/kevin/esp-idf/components/soc/include -I/home/kevin/esp-idf/components/soc/esp32/. -I/home/kevin/esp-idf/components/soc/esp32/include -I/home/kevin/esp-idf/components/hal/esp32/include -I/home/kevin/esp-idf/components/hal/include -I/home/kevin/esp-idf/components/esp_rom/include -I/home/kevin/esp-idf/components/esp_rom/esp32 -I/home/kevin/esp-idf/components/esp_rom/include/esp32 -I/home/kevin/esp-idf/components/esp_common/include -I/home/kevin/esp-idf/components/esp_system/include -I/home/kevin/esp-idf/components/esp32/include -I/home/kevin/esp-idf/components/driver/include -I/home/kevin/esp-idf/components/driver/esp32/include -I/home/kevin/esp-idf/components/esp_ringbuf/include -I/home/kevin/esp-idf/components/efuse/include -I/home/kevin/esp-idf/components/efuse/esp32/include -I/home/kevin/esp-idf/components/xtensa/include -I/home/kevin/esp-idf/components/xtensa/esp32/include -I/home/kevin/esp-idf/components/espcoredump/include -I/home/kevin/esp-idf/components/esp_timer/include -I/home/kevin/esp-idf/components/esp_ipc/include -I/home/kevin/esp-idf/components/esp_pm/include -I/home/kevin/esp-idf/components/vfs/include -I/home/kevin/esp-idf/components/esp_wifi/include -I/home/kevin/esp-idf/components/esp_wifi/esp32/include -I/home/kevin/esp-idf/components/esp_event/include -I/home/kevin/esp-idf/components/esp_netif/include -I/home/kevin/esp-idf/components/tcpip_adapter/include -I/home/kevin/esp-idf/components/app_trace/include -I/home/kevin/esp-adf/components/audio_sal/include -I/home/kevin/esp-idf/components/nvs_flash/include -I/home/kevin/esp-idf/components/spi_flash/include -I/home/kevin/esp-idf/components/mbedtls/port/include -I/home/kevin/esp-idf/components/mbedtls/mbedtls/include -I/home/kevin/esp-idf/components/mbedtls/esp_crt_bundle/include -mlongcalls -Wno-frame-address   -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -O2 -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.3-194-g5b5e46971-dirty\" -DESP_PLATFORM -MD -MT esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/dram_list.c.obj -MF esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/dram_list.c.obj.d -o esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/dram_list.c.obj   -c /home/kevin/esp-adf/components/playlist/playlist_operator/dram_list.c
/home/kevin/esp-adf/components/playlist/playlist_operator/dram_list.c: In function 'dram_list_save':
/home/kevin/esp-adf/components/playlist/playlist_operator/dram_list.c:90:5: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
     strncpy(list_node->url_name, url, strlen(url));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
[1309/1371] Building C object esp-idf/playlist/CMakeFiles/__idf_playlist.dir/playlist_operator/partition_list.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
kevin@ubuntu:~/workspace/liberty$ 

Who is online

Users browsing this forum: No registered users and 105 guests