MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.36k stars 19.26k forks source link

[BUG] Warning generated when enabling SDSUPPORT and LPC1768 architecture (potential buffer overflow) #24930

Closed DanM365 closed 2 years ago

DanM365 commented 2 years ago

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

In 2.1.x bugfix code, when compiling for MKS_SGEN_L (LPC1768) and endabling SDSUPPORT, I get the following errors:

In file included from Marlin\src\lcd\dogm../../inc/../HAL/./LPC1768/../shared/Marduino.h:36, from Marlin\src\lcd\dogm../../inc/../HAL/./LPC1768/HAL.h:37, from Marlin\src\lcd\dogm../../inc/../HAL/HAL.h:30, from Marlin\src\lcd\dogm../../inc/MarlinConfig.h:31, from Marlin\src\lcd\dogm\dogm_Statusscreen.h:31, from Marlin\src\lcd\dogm\status_screen_DOGM.cpp:32: Marlin\src\lcd\dogm../../module/../libs/duration_t.h: In static member function 'static void MarlinUI::draw_status_screen()': Marlin\src\lcd\dogm../../module/../libs/duration_t.h:161:30: warning: '%02hu' directive writing 2 bytes into a region of size between 0 and 4 [-Wformat-overflow=] 161 | sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 C:\Users\danma.platformio\packages\framework-arduino-lpc176x\cores\arduino/Arduino.h:58:18: note: in definition of macro 'PSTR' 58 | #define PSTR(v) (v) | ^ Marlin\src\lcd\dogm../../module/../libs/duration_t.h:161:30: note: directive argument in the range [0, 59] 161 | sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 C:\Users\danma.platformio\packages\framework-arduino-lpc176x\cores\arduino/Arduino.h:58:18: note: in definition of macro 'PSTR' 58 | #define PSTR(v) (v) | ^ In file included from Marlin\src\lcd\dogm../../module/printcounter.h:25, from Marlin\src\lcd\dogm../marlinui.h:39, from Marlin\src\lcd\dogm\status_screen_DOGM.cpp:34: Marlin\src\lcd\dogm../../module/../libs/duration_t.h:161:16: note: 'sprintf' output between 9 and 13 bytes into a destination of size 10 161 | sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45

Bug Timeline

Not sure when it started. Migrating from 2.0.8 build.

Expected behavior

Should not generate a warning. Is the sprintf buffer too small, or are the parameters wrong?

Actual behavior

Noy yet know as this is a "potential" overflow.

Steps to Reproduce

Compile for MKS_SGEN_L and include SDSUPPORT.

Version of Marlin Firmware

2.1.x

Printer model

Custom rebuilt BIBO

Electronics

MKS_SGEN_L

Add-ons

Generic RepRap FullGraphic Controller

Bed Leveling

UBL Bilinear mesh

Your Slicer

Cura

Host Software

OctoPrint

Don't forget to include

Additional information & file uploads

Configuration.zip

thisiskeithb commented 2 years ago

Duplicate of https://github.com/MarlinFirmware/Marlin/issues/24907

thisiskeithb commented 2 years ago

You can ignore the warning.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.