diff --git a/src/ControlManager.cpp b/src/ControlManager.cpp index 7f1dfc4..ff19ab3 100644 --- a/src/ControlManager.cpp +++ b/src/ControlManager.cpp @@ -1151,29 +1151,29 @@ void Control::sendSourcesStatus(const IpEndpointName &remoteEndpoint, osc::Recei // return status of all listed sources (up to N) for (; i < Mixer::manager().numSource() && i < (int) N; ++i) { // send status of currently selected - sprintf(oscaddr, OSC_PREFIX OSC_CURRENT "/%d", i); + snprintf(oscaddr, 128, OSC_PREFIX OSC_CURRENT "/%d", i); p << osc::BeginMessage( oscaddr ) << (index_current == i ? 1.f : 0.f) << osc::EndMessage; // send status of alpha - sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i); + snprintf(oscaddr, 128, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i); p << osc::BeginMessage( oscaddr ) << Mixer::manager().sourceAtIndex(i)->alpha() << osc::EndMessage; // send name - sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_NAME, i); + snprintf(oscaddr, 128, OSC_PREFIX "/%d" OSC_SOURCE_NAME, i); p << osc::BeginMessage( oscaddr ) << Mixer::manager().sourceAtIndex(i)->name().c_str() << osc::EndMessage; } // zeros for non listed sources for (; i < (int) N ; ++i) { // reset status of currently selected - sprintf(oscaddr, OSC_PREFIX OSC_CURRENT "/%d", i); + snprintf(oscaddr, 128, OSC_PREFIX OSC_CURRENT "/%d", i); p << osc::BeginMessage( oscaddr ) << 0.f << osc::EndMessage; // reset status of alpha - sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i); + snprintf(oscaddr, 128, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i); p << osc::BeginMessage( oscaddr ) << 0.f << osc::EndMessage; /// name - sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_NAME, i); + snprintf(oscaddr, 128, OSC_PREFIX "/%d" OSC_SOURCE_NAME, i); p << osc::BeginMessage( oscaddr ) << "" << osc::EndMessage; } @@ -1203,7 +1203,7 @@ void Control::sendBatchStatus(const IpEndpointName &remoteEndpoint) // batch list for (auto plit = pl.begin(); plit != pl.end(); ++plit, ++i) { - sprintf(oscaddr, OSC_PREFIX "/batch#%d/index" , i); + snprintf(oscaddr, 128, OSC_PREFIX "/batch#%d/index" , i); p << osc::BeginMessage( oscaddr ); for (auto id = plit->begin(); id != plit->end(); ++id) { @@ -1217,7 +1217,7 @@ void Control::sendBatchStatus(const IpEndpointName &remoteEndpoint) i = 0; for (auto plit = pl.begin(); plit != pl.end(); ++plit, ++i) { - sprintf(oscaddr, OSC_PREFIX "/batch#%d" OSC_SOURCE_ALPHA, i); + snprintf(oscaddr, 128, OSC_PREFIX "/batch#%d" OSC_SOURCE_ALPHA, i); p << osc::BeginMessage( oscaddr ); for (auto id = plit->begin(); id != plit->end(); ++id) { diff --git a/src/ImGuiToolkit.cpp b/src/ImGuiToolkit.cpp index 3984917..cc5d14a 100644 --- a/src/ImGuiToolkit.cpp +++ b/src/ImGuiToolkit.cpp @@ -48,7 +48,7 @@ std::map fontmap; void ImGuiToolkit::ButtonOpenUrl( const char* label, const char* url, const ImVec2& size_arg ) { char _label[512]; - sprintf( _label, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, label ); + snprintf( _label, 512, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, label ); if ( ImGui::Button(_label, size_arg) ) SystemToolkit::open(url); @@ -1313,7 +1313,7 @@ bool ImGuiToolkit::EditPlotLines (const char* label, float *array, int values_co // plot lines char buf[128]; - sprintf(buf, "##Lines%s", label); + snprintf(buf, 128, "##Lines%s", label); ImGui::PushStyleColor(ImGuiCol_FrameBg, bg_color); ImGui::PlotLines(buf, array, values_count, 0, NULL, values_min, values_max, size); @@ -1439,7 +1439,7 @@ bool ImGuiToolkit::EditPlotHistoLines (const char* label, float *histogram_array ImGui::PushStyleColor(ImGuiCol_FrameBg, bg_color); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, style.Colors[ImGuiCol_ModalWindowDimBg]); // a dark color char buf[128]; - sprintf(buf, "##Histo%s", label); + snprintf(buf, 128, "##Histo%s", label); ImGui::PlotHistogram(buf, histogram_array, values_count, 0, NULL, values_min, values_max, size); ImGui::PopStyleColor(2); @@ -1447,7 +1447,7 @@ bool ImGuiToolkit::EditPlotHistoLines (const char* label, float *histogram_array // plot (transparent) lines ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0,0,0,0)); - sprintf(buf, "##Lines%s", label); + snprintf(buf, 128, "##Lines%s", label); ImGui::PlotLines(buf, lines_array, values_count, 0, NULL, values_min, values_max, size); ImGui::PopStyleColor(1); @@ -1515,7 +1515,7 @@ void ImGuiToolkit::ShowPlotHistoLines (const char* label, float *histogram_array ImGui::PushStyleColor(ImGuiCol_FrameBg, bg_color); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0, 0, 0, 250)); char buf[128]; - sprintf(buf, "##Histo%s", label); + snprintf(buf, 128, "##Histo%s", label); ImGui::PlotHistogram(buf, histogram_array, values_count, 0, NULL, values_min, values_max, size); ImGui::PopStyleColor(2); @@ -1523,7 +1523,7 @@ void ImGuiToolkit::ShowPlotHistoLines (const char* label, float *histogram_array // plot lines ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0,0,0,0)); - sprintf(buf, "##Lines%s", label); + snprintf(buf, 128, "##Lines%s", label); ImGui::PlotLines(buf, lines_array, values_count, 0, NULL, values_min, values_max, size); ImGui::PopStyleColor(1); @@ -1947,7 +1947,7 @@ bool ImGuiToolkit::InputCodeMultiline(const char* label, std::string *str, const { bool ret = false; char hiddenlabel[256]; - sprintf(hiddenlabel, "##%s", label); + snprintf(hiddenlabel, 256, "##%s", label); // Draw the label with default font ImVec2 pos_top = ImGui::GetCursorPos(); @@ -1987,7 +1987,7 @@ bool ImGuiToolkit::InputCodeMultiline(const char* label, std::string *str, const void ImGuiToolkit::CodeMultiline(const char* label, const std::string &str, float width) { char hiddenlabel[256]; - sprintf(hiddenlabel, "##%s", label); + snprintf(hiddenlabel, 256, "##%s", label); ImGuiToolkit::PushFont(FONT_MONO); static ImVec2 onechar = ImGui::CalcTextSize("C"); diff --git a/src/InputMappingWindow.cpp b/src/InputMappingWindow.cpp index d3155a4..c1aff5e 100644 --- a/src/InputMappingWindow.cpp +++ b/src/InputMappingWindow.cpp @@ -428,7 +428,7 @@ void InputMappingWindow::SliderParametersCallback(SourceCallback *callback, cons static std::regex RegExTime("([0-9]+\\:)*([0-5][0-9]|[0-9])(\\.[0-9]+)*"); struct TextFilters { static int FilterTime(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("0123456789.:", (char)data->EventChar)) return 0; return 1; } }; char buf6[64] = ""; - sprintf(buf6, "%d:%.2f", min, sec ); + snprintf(buf6, 64, "%d:%.2f", min, sec ); // Text input field for MM:SS:MS seek target time ImGui::SetNextItemWidth(right_align); diff --git a/src/Log.cpp b/src/Log.cpp index 187221c..9f2e8ea 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -75,7 +75,7 @@ struct AppLog // normal title char window_title[1024]; - sprintf(window_title, "%s ###LOGVIMIX", title); + snprintf(window_title, 1024, "%s ###LOGVIMIX", title); if (*p_open) { // if open but Collapsed, create title of window with last line of logs @@ -84,7 +84,7 @@ struct AppLog size_t lenght = LineOffsets[LineOffsets.Size-1] - LineOffsets[LineOffsets.Size-2] - 1; memset(lastlogline, '\0', 128); memcpy(lastlogline, Buf.begin() + LineOffsets[LineOffsets.Size-2], MIN(127, lenght)); - sprintf(window_title, "%s - %s ###LOGVIMIX", title, lastlogline); + snprintf(window_title, 1024, "%s - %s ###LOGVIMIX", title, lastlogline); } } diff --git a/src/OutputPreviewWindow.cpp b/src/OutputPreviewWindow.cpp index 16c5dcb..cdf532d 100644 --- a/src/OutputPreviewWindow.cpp +++ b/src/OutputPreviewWindow.cpp @@ -304,13 +304,13 @@ void OutputPreviewWindow::Render() if ( name_path[0] == nullptr ) { for (int i = 0; i < 4; ++i) name_path[i] = (char *) malloc( 1024 * sizeof(char)); - sprintf( name_path[1], "%s", ICON_FA_HOME " Home"); - sprintf( name_path[2], "%s", ICON_FA_FOLDER " Session location"); - sprintf( name_path[3], "%s", ICON_FA_FOLDER_PLUS " Select"); + snprintf( name_path[1], 1024, "%s", ICON_FA_HOME " Home"); + snprintf( name_path[2], 1024, "%s", ICON_FA_FOLDER " Session location"); + snprintf( name_path[3], 1024, "%s", ICON_FA_FOLDER_PLUS " Select"); } if (Settings::application.record.path.empty()) Settings::application.record.path = SystemToolkit::home_path(); - sprintf( name_path[0], "%s", Settings::application.record.path.c_str()); + snprintf( name_path[0], 1024, "%s", Settings::application.record.path.c_str()); int selected_path = 0; ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Path", &selected_path, name_path, 4); @@ -595,7 +595,7 @@ void OutputPreviewWindow::Render() ImGui::Text("To do so, the following commands should be executed\n(with admin rights):"); static char dummy_str[512]; - sprintf(dummy_str, "sudo apt install v4l2loopback-dkms"); + snprintf(dummy_str, 512, "sudo apt install v4l2loopback-dkms"); ImGui::NewLine(); ImGui::Text("Install v4l2loopack (only once, and reboot):"); ImGui::SetNextItemWidth(600-40); @@ -606,7 +606,7 @@ void OutputPreviewWindow::Render() ImGui::SetClipboardText(dummy_str); ImGui::PopID(); - sprintf(dummy_str, "sudo modprobe v4l2loopback exclusive_caps=1 video_nr=%d" + snprintf(dummy_str, 512, "sudo modprobe v4l2loopback exclusive_caps=1 video_nr=%d" " card_label=\"vimix loopback\"" , Settings::application.loopback_camera); ImGui::NewLine(); ImGui::Text("Initialize v4l2loopack:"); diff --git a/src/Source.cpp b/src/Source.cpp index d8639d3..4ddba75 100644 --- a/src/Source.cpp +++ b/src/Source.cpp @@ -122,7 +122,7 @@ Source::Source(uint64_t id) : SourceCore(), id_(id), ready_(false), symbol_(null if (id_ == 0) id_ = BaseToolkit::uniqueId(); - sprintf(initials_, "__"); + snprintf(initials_, 3, "__"); name_ = "Source"; mode_ = Source::UNINITIALIZED; diff --git a/src/SourceControlWindow.cpp b/src/SourceControlWindow.cpp index f56ee30..3d7ecdb 100644 --- a/src/SourceControlWindow.cpp +++ b/src/SourceControlWindow.cpp @@ -331,13 +331,13 @@ void SourceControlWindow::Render() if ( name_path[0] == nullptr ) { for (int i = 0; i < 4; ++i) name_path[i] = (char *) malloc( 1024 * sizeof(char)); - sprintf( name_path[1], "%s", ICON_FA_HOME " Home"); - sprintf( name_path[2], "%s", ICON_FA_FOLDER " File location"); - sprintf( name_path[3], "%s", ICON_FA_FOLDER_PLUS " Select"); + snprintf( name_path[1], 1024, "%s", ICON_FA_HOME " Home"); + snprintf( name_path[2], 1024, "%s", ICON_FA_FOLDER " File location"); + snprintf( name_path[3], 1024, "%s", ICON_FA_FOLDER_PLUS " Select"); } if (Settings::application.source.capture_path.empty()) Settings::application.source.capture_path = SystemToolkit::home_path(); - sprintf( name_path[0], "%s", Settings::application.source.capture_path.c_str()); + snprintf( name_path[0], 1024, "%s", Settings::application.source.capture_path.c_str()); int selected_path = 0; ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); ImGui::Combo("Path", &selected_path, name_path, 4); diff --git a/src/SystemToolkit.cpp b/src/SystemToolkit.cpp index 8853aee..ab35ff8 100644 --- a/src/SystemToolkit.cpp +++ b/src/SystemToolkit.cpp @@ -341,11 +341,11 @@ void SystemToolkit::open(const string& url) ShellExecuteA( nullptr, nullptr, url.c_str(), nullptr, nullptr, 0 ); #elif defined APPLE char buf[2048]; - sprintf( buf, "open '%s'", url.c_str() ); + snprintf( buf, 2048, "open '%s'", url.c_str() ); ignored = system( buf ); #else char buf[2048]; - sprintf( buf, "xdg-open '%s'", url.c_str() ); + snprintf( buf, 2048, "xdg-open '%s'", url.c_str() ); ignored = system( buf ); #endif } diff --git a/src/TimerMetronomeWindow.cpp b/src/TimerMetronomeWindow.cpp index 71a702f..a4ca72f 100644 --- a/src/TimerMetronomeWindow.cpp +++ b/src/TimerMetronomeWindow.cpp @@ -178,7 +178,7 @@ void TimerMetronomeWindow::Render() draw_list->AddCircleFilled(circle_center, margin, colorfg, PLOT_CIRCLE_SEGMENTS); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); char text_buf[24]; - sprintf(text_buf, "%d/%d", (int)(p)+1, (int)(q) ); + snprintf(text_buf, 24, "%d/%d", (int)(p)+1, (int)(q) ); ImVec2 label_size = ImGui::CalcTextSize(text_buf, NULL); ImGui::SetCursorScreenPos(circle_center - label_size/2); ImGui::Text("%s", text_buf); @@ -204,12 +204,12 @@ void TimerMetronomeWindow::Render() ImGui::SetCursorScreenPos(circle_top_right); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); ImGui::PushStyleColor(ImGuiCol_Text, colorfg); - sprintf(text_buf, "%d", (int) ceil(t) ); + snprintf(text_buf, 24, "%d", (int) ceil(t) ); ImGui::Text("%s", text_buf); ImGui::PopStyleColor(); ImGui::PopFont(); if (ImGui::IsItemHovered()){ - sprintf(text_buf, "%d BPM\n(set by peer)", (int) ceil(t)); + snprintf(text_buf, 24, "%d BPM\n(set by peer)", (int) ceil(t)); ImGuiToolkit::ToolTip(text_buf); } } @@ -218,13 +218,13 @@ void TimerMetronomeWindow::Render() // Tempo ImGui::SetCursorScreenPos(circle_top_right); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - sprintf(text_buf, "%d", (int) ceil(t) ); + snprintf(text_buf, 24, "%d", (int) ceil(t) ); ImGui::Text("%s", text_buf); ImGui::PopFont(); if (ImGui::IsItemClicked()) ImGui::OpenPopup("bpm_popup"); else if (ImGui::IsItemHovered()){ - sprintf(text_buf, "%d BPM\n(clic to edit)", (int) ceil(t)); + snprintf(text_buf, 24, "%d BPM\n(clic to edit)", (int) ceil(t)); ImGuiToolkit::ToolTip(text_buf); } if (ImGui::BeginPopup("bpm_popup", ImGuiWindowFlags_NoMove)) @@ -253,7 +253,7 @@ void TimerMetronomeWindow::Render() ImGui::SetCursorScreenPos(circle_botom_right); ImGuiToolkit::Icon(16, 5, np > 0); if (ImGui::IsItemHovered()){ - sprintf(text_buf, np < 1 ? "Ableton Link\nNo peer" : "Ableton Link\n%d peer%c", np, np < 2 ? ' ' : 's' ); + snprintf(text_buf, 24, np < 1 ? "Ableton Link\nNo peer" : "Ableton Link\n%d peer%c", np, np < 2 ? ' ' : 's' ); ImGuiToolkit::ToolTip(text_buf); } } @@ -288,7 +288,7 @@ void TimerMetronomeWindow::Render() // main text: elapsed time ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); char text_buf[24]; - sprintf(text_buf, "%s", GstToolkit::time_to_string(time_-start_time_, GstToolkit::TIME_STRING_FIXED).c_str() ); + snprintf(text_buf, 24, "%s", GstToolkit::time_to_string(time_-start_time_, GstToolkit::TIME_STRING_FIXED).c_str() ); ImVec2 label_size = ImGui::CalcTextSize(text_buf, NULL); ImGui::SetCursorScreenPos(circle_center - label_size/2); ImGui::Text("%s", text_buf); @@ -299,12 +299,12 @@ void TimerMetronomeWindow::Render() ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); guint64 lap = (time_-start_time_hand_)/duration_hand_; - sprintf(text_buf, "%ld turn%s", lap, lap > 1 ? "s" : " " ); + snprintf(text_buf, 24, "%ld turn%s", lap, lap > 1 ? "s" : " " ); label_size = ImGui::CalcTextSize(text_buf, NULL); ImGui::SetCursorScreenPos(circle_center + ImVec2(0.f, circle_radius * -0.7f) - label_size/2); ImGui::Text("%s", text_buf); - sprintf(text_buf, "%s", GstToolkit::time_to_string(duration_hand_-(time_-start_time_hand_)%duration_hand_, GstToolkit::TIME_STRING_READABLE).c_str() ); + snprintf(text_buf, 24, "%s", GstToolkit::time_to_string(duration_hand_-(time_-start_time_hand_)%duration_hand_, GstToolkit::TIME_STRING_READABLE).c_str() ); label_size = ImGui::CalcTextSize(text_buf, NULL); ImGui::SetCursorScreenPos(circle_center - ImVec2(0.f, circle_radius * -0.7f) - label_size/2); ImGui::Text("%s", text_buf); diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 08ae475..d6e1cb1 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -196,7 +196,7 @@ bool UserInterface::Init() // setup settings filename std::string inifile = SystemToolkit::full_filename(SystemToolkit::settings_path(), "imgui.ini"); - std::sprintf(inifilepath, "%s", inifile.c_str() ); + std::snprintf(inifilepath, 2048, "%s", inifile.c_str() ); io.IniFilename = inifilepath; // init dialogs @@ -1316,7 +1316,7 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) if (*p_mode & Metrics_framerate) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - sprintf(dummy_str, "%.1f", io.Framerate); + snprintf(dummy_str, 256, "%.1f", io.Framerate); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1328,7 +1328,7 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) if (*p_mode & Metrics_ram) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - sprintf(dummy_str, "%s", BaseToolkit::byte_to_string( ram ).c_str()); + snprintf(dummy_str, 256, "%s", BaseToolkit::byte_to_string( ram ).c_str()); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy2", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1343,10 +1343,10 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); // got free and max GPU RAM (nvidia) if (gpu.y < INT_MAX && gpu.y > 0) - sprintf(dummy_str, "%s", BaseToolkit::byte_to_string( long(gpu.y-gpu.x) * 1024 ).c_str()); + snprintf(dummy_str, 256, "%s", BaseToolkit::byte_to_string( long(gpu.y-gpu.x) * 1024 ).c_str()); // got used GPU RAM (ati) else - sprintf(dummy_str, "%s", BaseToolkit::byte_to_string( long(gpu.x) * 1024 ).c_str()); + snprintf(dummy_str, 256, "%s", BaseToolkit::byte_to_string( long(gpu.x) * 1024 ).c_str()); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy3", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1358,7 +1358,7 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) if (*p_mode & Metrics_session) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - sprintf(dummy_str, "%s", GstToolkit::time_to_string(Mixer::manager().session()->runtime(), GstToolkit::TIME_STRING_READABLE).c_str()); + snprintf(dummy_str, 256, "%s", GstToolkit::time_to_string(Mixer::manager().session()->runtime(), GstToolkit::TIME_STRING_READABLE).c_str()); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1370,7 +1370,7 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) if (*p_mode & Metrics_runtime) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - sprintf(dummy_str, "%s", GstToolkit::time_to_string(time, GstToolkit::TIME_STRING_READABLE).c_str()); + snprintf(dummy_str, 256, "%s", GstToolkit::time_to_string(time, GstToolkit::TIME_STRING_READABLE).c_str()); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy2", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1383,7 +1383,7 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) if (*p_mode & Metrics_lifetime) { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); time += Settings::application.total_runtime; - sprintf(dummy_str, "%s", GstToolkit::time_to_string(time, GstToolkit::TIME_STRING_READABLE).c_str()); + snprintf(dummy_str, 256, "%s", GstToolkit::time_to_string(time, GstToolkit::TIME_STRING_READABLE).c_str()); ImGui::SetNextItemWidth(_width); ImGui::InputText("##dummy3", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -2193,11 +2193,11 @@ void ToolBox::Render() ImVec2 plot_size = ImGui::GetContentRegionAvail(); plot_size.y *= 0.32; char overlay[128]; - sprintf(overlay, "Rendering %.1f FPS", recorded_sum[0] / float(PLOT_ARRAY_SIZE)); + snprintf(overlay, 128, "Rendering %.1f FPS", recorded_sum[0] / float(PLOT_ARRAY_SIZE)); ImGui::PlotLines("LinesRender", recorded_values[0], PLOT_ARRAY_SIZE, values_index, overlay, recorded_bounds[0][0], recorded_bounds[0][1], plot_size); - sprintf(overlay, "Update time %.1f ms (%.1f FPS)", recorded_sum[1] / float(PLOT_ARRAY_SIZE), (float(PLOT_ARRAY_SIZE) * 1000.f) / recorded_sum[1]); + snprintf(overlay, 128, "Update time %.1f ms (%.1f FPS)", recorded_sum[1] / float(PLOT_ARRAY_SIZE), (float(PLOT_ARRAY_SIZE) * 1000.f) / recorded_sum[1]); ImGui::PlotHistogram("LinesMixer", recorded_values[1], PLOT_ARRAY_SIZE, values_index, overlay, recorded_bounds[1][0], recorded_bounds[1][1], plot_size); - sprintf(overlay, "Memory %.1f MB", recorded_values[2][(values_index+PLOT_ARRAY_SIZE-1) % PLOT_ARRAY_SIZE] ); + snprintf(overlay, 128, "Memory %.1f MB", recorded_values[2][(values_index+PLOT_ARRAY_SIZE-1) % PLOT_ARRAY_SIZE] ); ImGui::PlotLines("LinesMemo", recorded_values[2], PLOT_ARRAY_SIZE, values_index, overlay, recorded_bounds[2][0], recorded_bounds[2][1], plot_size); ImGui::End(); @@ -4150,18 +4150,18 @@ void Navigator::RenderMainPannelVimix() static char dummy_str[512]; ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.14f, 0.14f, 0.14f, 0.9f)); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - sprintf(dummy_str, "%s", RenderView::ratio_preset_name[preset.x]); + snprintf(dummy_str, 512, "%s", RenderView::ratio_preset_name[preset.x]); ImGui::InputText("Ratio", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); if (preset.x < RenderView::AspectRatio_Custom) { ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - sprintf(dummy_str, "%s", RenderView::height_preset_name[preset.y]); + snprintf(dummy_str, 512, "%s", RenderView::height_preset_name[preset.y]); ImGui::InputText("Height", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); } else { ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - sprintf(dummy_str, "%d", custom.x); + snprintf(dummy_str, 512, "%d", custom.x); ImGui::InputText("Width", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); - sprintf(dummy_str, "%d", custom.y); + snprintf(dummy_str, 512, "%d", custom.y); ImGui::InputText("Height", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly); } ImGui::PopStyleColor(1); @@ -4625,7 +4625,7 @@ void Navigator::RenderMainPannelSettings() if (output) { guint64 nb = 0; nb = VideoRecorder::buffering_preset_value[Settings::application.record.buffering_mode] / (output->width() * output->height() * 4); - char buf[512]; sprintf(buf, "Buffer at %s can contain %ld frames (%dx%d), i.e. %.1f sec", VideoRecorder::buffering_preset_name[Settings::application.record.buffering_mode], + char buf[512]; snprintf(buf, 512, "Buffer at %s can contain %ld frames (%dx%d), i.e. %.1f sec", VideoRecorder::buffering_preset_name[Settings::application.record.buffering_mode], (unsigned long)nb, output->width(), output->height(), (float)nb / (float) VideoRecorder::framerate_preset_value[Settings::application.record.framerate_mode] ); ImGuiToolkit::Indication(buf, 4, 6); @@ -4674,7 +4674,7 @@ void Navigator::RenderMainPannelSettings() ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufport[7] = ""; - sprintf(bufport, "%d", Settings::application.broadcast_port); + snprintf(bufport, 7, "%d", Settings::application.broadcast_port); ImGui::InputTextWithHint("SRT Port", "7070", bufport, 6, ImGuiInputTextFlags_CharsDecimal); if (ImGui::IsItemDeactivatedAfterEdit()){ if ( BaseToolkit::is_a_number(bufport, &Settings::application.broadcast_port)) @@ -4709,7 +4709,7 @@ void Navigator::RenderMainPannelSettings() ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufsocket[64] = ""; - sprintf(bufsocket, "%s", Settings::application.shm_socket_path.c_str()); + snprintf(bufsocket, 64, "%s", Settings::application.shm_socket_path.c_str()); ImGui::InputTextWithHint("SHM path", SystemToolkit::home_path().c_str(), bufsocket, 64); if (ImGui::IsItemDeactivatedAfterEdit()) { Settings::application.shm_socket_path = bufsocket; @@ -4743,7 +4743,7 @@ void Navigator::RenderMainPannelSettings() ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufreceive[7] = ""; - sprintf(bufreceive, "%d", Settings::application.control.osc_port_receive); + snprintf(bufreceive, 7, "%d", Settings::application.control.osc_port_receive); ImGui::InputTextWithHint("Port in", "7000", bufreceive, 7, ImGuiInputTextFlags_CharsDecimal); if (ImGui::IsItemDeactivatedAfterEdit()){ if ( BaseToolkit::is_a_number(bufreceive, &Settings::application.control.osc_port_receive)){ @@ -4755,7 +4755,7 @@ void Navigator::RenderMainPannelSettings() ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); char bufsend[7] = ""; - sprintf(bufsend, "%d", Settings::application.control.osc_port_send); + snprintf(bufsend, 7, "%d", Settings::application.control.osc_port_send); ImGui::InputTextWithHint("Port out", "7001", bufsend, 7, ImGuiInputTextFlags_CharsDecimal); if (ImGui::IsItemDeactivatedAfterEdit()){ if ( BaseToolkit::is_a_number(bufsend, &Settings::application.control.osc_port_send)){ diff --git a/src/WorkspaceWindow.cpp b/src/WorkspaceWindow.cpp index 9d0a468..58db45e 100644 --- a/src/WorkspaceWindow.cpp +++ b/src/WorkspaceWindow.cpp @@ -202,7 +202,7 @@ void WorkspaceWindow::Update() ImGui::SetNextWindowPos(window->Pos, ImGuiCond_Always); ImGui::SetNextWindowSize(window->Size, ImGuiCond_Always); char nameoverlay[64]; - sprintf(nameoverlay, "%sOverlay", name_); + snprintf(nameoverlay, 64, "%sOverlay", name_); if (ImGui::Begin(nameoverlay, NULL, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings )) { // exit workspace clear mode if user clics on the window