Switch to using snprintf instead of sprintf

This commit is contained in:
Abdelrahman Said
2024-10-07 08:01:33 +01:00
parent 36e88ba84d
commit 1108ed686e
3 changed files with 38 additions and 35 deletions

View File

@@ -27,7 +27,7 @@ TestFuncResult test_commander_cmd_out_buf_success(void) {
char expected_output[64] = {0};
const char *msg = "hello world";
u64 length = strlen(msg);
sprintf(expected_output, "%s\n", msg);
snprintf(expected_output, length + 2, "%s\n", msg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, buf, 64, "echo", msg);
bool succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&