mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 07:40:23 +02:00
Fix for unsafe ctime
usage (CWE-676)
Replace unneeded and unsafe usage of `ctime` with `chrono` based timing. Signed-off-by: Emily Mabrey <emabrey@tenacityaudio.org> Reference-to: https://github.com/tenacityteam/tenacity/pull/394
This commit is contained in:
parent
e06af5bb29
commit
a21a554f5b
@ -26,6 +26,10 @@ but it will probably work fine if you use it on a high level.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wx/crt.h>
|
||||
#include <time.h>
|
||||
#include <chrono>
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
///write to a profile at the end of the test.
|
||||
Profiler::~Profiler()
|
||||
@ -33,12 +37,12 @@ Profiler::~Profiler()
|
||||
if(mTasks.size())
|
||||
{
|
||||
//print everything out. append to a log.
|
||||
FILE* log = fopen("AudacityProfilerLog.txt", "a");
|
||||
time_t now;
|
||||
FILE* log = fopen("TenacityProfilerLog.txt", "a");
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::uint64_t timestamp_ms = now.time_since_epoch() / std::chrono::milliseconds(1);
|
||||
|
||||
time(&now);
|
||||
wxFprintf(log,"Audacity Profiler Run, Ended at ");
|
||||
wxFprintf(log,"%s",ctime(&now));
|
||||
wxFprintf(log,"Tenacity Profiler Run, Ended at ");
|
||||
wxFprintf(log,"%" PRIu64,timestamp_ms);
|
||||
wxFprintf(log,"****************************************\n");
|
||||
//print out the tasks
|
||||
for(int i=0;i<(int)mTasks.size();i++)
|
||||
|
@ -28,7 +28,6 @@ but it will probably work fine if you use it on a high level.
|
||||
#define __AUDACITY_PROFILER__
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include "MemoryX.h"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user